我最近进入BDD并认为它有很大的希望,作为一种方式,让我们作为开发人员为他们创建的应用程序中的利益相关者的声音.你最喜欢的BDD框架是什么?为什么?
我是MSpec的忠实粉丝所以我很自然地想要使用VS2010.我将MSpec运行程序定义为Visual Studio中的外部工具,以使其始终可见为工具栏项.
无论如何,每当我尝试在.NET 4.0解决方案中使用MSpec runner(mspec.exe)时,我都会收到以下错误:
Could not load file or assembly 'file:///C:\Users\[SOMEUSER]\[SOME_FOLDERS]\bin\Debug\[PROJECT].Specs.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
我仍然可以使用Resharper 5跑步者来运行我的规格,所以这不是什么大戏,但是让我困扰不已:þ
你们知道问题是什么吗?除了将整个Mspec源代码重新编译为.NET 4.0解决方案之外,还有其他解决方案,我真的,真的不想这样做吗?
提前致谢.
塞尔吉
当我创建如下所示的新测试时:
它should_get_something =()=> foo();
当我在代表的前面点击分叉的resharper stick时:
Private It should_get_something =()=> foo();
然后我必须删除它.
我可以告诉resharper不要这样做吗?我尝试在命名样式对话框中添加一个规则,选择Machine.Specifications.It并取消选中Private,但这没有任何效果.
我刚开始学习和使用ASP.NET MVC 2,并且更多地参与单元测试我的代码.我的问题是如何通过在我的测试中传入凭据来模拟用户登录.
我正在使用MSpec,并试图让我的头脑周围的假冒为了写我的测试.到目前为止,我相信我已经正确地编写了一个测试(它通过了测试条件),以供未经身份验证的用户尝试访问页面时使用.
Subject( typeof( HomeController ) )]
public class context_for_a_home_controller_for_not_logged_user
{
protected static HomeController HomeController;
Establish context = () =>
{
// Create controller
HomeController = new HomeController();
HomeController.ControllerContext = A.Fake<ControllerContext>();
};
}
[Subject(typeof(HomeController))]
public class when_the_home_page_is_requested : context_for_a_home_controller_for_not_logged_user
{
static ActionResult result;
Because of = () =>
result = HomeController.Index();
It should_return_the_log_in_page_if_user_not_logged_in = () =>
{ result.ShouldBeAView().And().ShouldUseDefaultView(); };
}
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.但是,我想测试经过身份验证的用户何时命中主控制器的情况.我坚持如何模拟经过身份验证的用户,欢迎任何帮助或建议.
TIA,
大卫
我正在使用Behaviors和Behaves_like字段编写惯用的MSpec规范
[Subject(typeof(IUnitMaskConverter))]
public class When_converting_unit_masks_by_lookup
{
Behaves_like<UnitMaskConverterBehaviors> a_unit_mask_converter;
protected static LookupUnitMaskConverter _converter = new LookupUnitMaskConverter();
}
Run Code Online (Sandbox Code Playgroud)
Visual Studio显示构建警告
The field 'Specs.UnitMask.When_converting_unit_masks_by_lookup.a_unit_mask_converter' is never used
Run Code Online (Sandbox Code Playgroud)
我已经熟悉MSpec的ReSharper代码注释,并且我有MSpec主题和字段的命名规则.我不知道如何控制未使用字段的此警告.我想避免在项目级别压制警告,因为它在常规情况下实际上很有用.
在TeamCity中运行MSpec构建步骤时,我在团队城市日志中收到以下错误:
[Step 7/7] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit
[17:07:13][Step 7/7] in directory: C:\TeamCity\buildAgent\work\726e90173bc65483
[17:07:14][Step 7/7] 2012-10-02 17:07:14,471 [4332] ERROR JetBrains.TeamCity.Utils.Runtime.ParseUtil - Failed to load assembly from file c:\mspec\mspec.exe: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Mspec的ShouldBeOfType<T>()断言扩展方法,但intellisense说它无法找到它.我正在使用MSpec v0.7.0.我尝试使用Nuget重新安装,但没有用.
[Subject("Prop Manager")]
public class When_Replying_To_Prop_Which_Already_Had_Emailed_And_No_Overwrite
{
Because of = () => _exception = Catch.Exception(() => _PropManager.ReplyToProp());
It should_result_in_an_error = () => _exception.ShouldBeOfType<InvalidOperationException>();
private static Exception _exception;
}
Run Code Online (Sandbox Code Playgroud) 我是行为驱动开发的新手,我正在努力学习它.我正在使用MSpec和Watin进行验收测试,并使用ASP.Net MVC 4进行单元测试的MSpec.我有一个简单的用户注册方案.
当用户输入用户名,密码,电子邮件等并点击注册按钮
时应验证电子邮件地址
应该检查用户名是否已经存在
它应该注册用户
它应该发送一个欢迎电子邮件
它应该重定向到主页
我想测试的东西无法使用Watin测试,例如发送电子邮件,检查用户是否存在等等.这些将是控制器测试的一部分.这是否意味着我的验收测试只会是当用户注册时他应该被重定向到主页?如何将整个过程分解为测试?
如果这些检查是在各种测试和不同级别实现的,那么如何获得MSpec提供的已实现所有功能的摘要报告?关于人们如何打破这些任务,然后他们如何获得集体报告等,我感到有点困惑.
我的理解是每个Establish应该只执行一次,但下面的代码显示它执行多次。我们嵌套类以提供一些分组,同时将主题的单元测试保留在一个文件中。这似乎是一个错误。
我们使用 machine.specations.runner.resharper Reshaper 扩展和 MSpec 0.9.1。
[Subject(typeof(string))]
internal class EstablishRunTwice {
Establish sharedContext = () => Console.WriteLine("Shared context");
internal class ScenarioA : EstablishRunTwice {
Establish scenarioAContext = () => Console.WriteLine("ScenarioA context");
internal class ScenarioAVariation1 : ScenarioA {
Because of = () => Console.WriteLine("ScenarioAVariation1 Because");
It it1 = () => Console.WriteLine("ScenarioAVariation1 It1");
It it2 = () => Console.WriteLine("ScenarioAVariation1 It2");
}
internal class ScenarioAVariation2 : ScenarioA {
Because of = () => Console.WriteLine("ScenarioAVariation2 Because");
It it1 = () => …Run Code Online (Sandbox Code Playgroud)