我正在开发一个asp.net mvc应用程序,并以BDD风格编写我的单元测试。
例如:
当资源文件存在时,GetResource_应返回资源()
但是,当我为控制器编写测试时,通常会有两个同名的方法。一个是没有参数的GET请求,另一个是有参数的POST请求。这里有没有好的命名约定可以区分这两个方法呢?
我能想到的有:
1.
LogIn_WithParameters_ShouldReturnLogInView()
LogIn_WithoutParameters_WhenAuthenticationFailed_ShouldReturnLogInView()
LogIn_WithoutParameters_WhenAuthenticationPassed_ShouldReturnProfileRedirect()
2.
LogIn_Get_ShouldReturnLogInView()
LogIn_Post_WhenAuthenticationFailed_ShouldReturnLogInView()
LogIn_Post_WhenAuthenticationPassed_ShouldReturnProfileRedirect()
3.
LogIn_ShouldReturnLogInView()
LogIn_WhenCalledWithParametersAndAuthenticationFailed_ShouldReturnLogInView()
LogIn_WhenCalledWithParametersAndAuthenticationPassed_ShouldReturnProfileRedirect()
你有什么想法吗?