问题标签 [mspec]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net-mvc - Machine.Specifications.MVC ShouldBeAView() 即使在有效的 ViewResults 上也总是失败
有没有人在使用 Machine.Specifications.Mvc 时遇到过这个问题?
我设置了一个规范来测试控制器操作的结果。在这种情况下:
我每次得到的错误是:
Machine.Specifications.SpecificationException:应该是 System.Web.Mvc.ViewResult 类型,但在 d:\BuildAgent-01 中的 Machine.Specifications.ShouldExtensionMethods.ShouldBeOfType(实际对象,预期类型)中是 System.Web.Mvc.ViewResult 类型\work\340c36596c29db8\Source\Machine.Specifications\ExtensionMethods.cs:第 206 行
有人见过这个吗?有没有简单的方法来解决它?它似乎发生在 Machine.Specifications 库中。我什至在调试模式下运行它来检查值,它们确实都是 ViewResult 对象,甚至具有正确的模型数据。
提前致谢
resharper - Spec fails when run by mspec.exe, but passes when run by TD.NET
I wrote about this topic in another question.
However, I've since refactored my code to get rid of configuration access, thus allowing the specs to pass. Or so I thought. They run fine from within Visual Studio using TestDriven.Net. However, when I run them during rake using the mspec.exe tool, they still fail with a serialization exception. So I've created a completely self-contained example that does basically nothing except setup fake security credentials on the thread. This test passes just fine in TD.Net, but blows up in mspec.exe. Does anybody have any suggestions?
Update: I've discovered a work-around. After researching the issue, it seems the cause is that the assembly containing my principal object is not in the same folder as the mspec.exe. When mspec creates a new AppDomain to run my specs, that new AppDomain has to load the assembly with the principal object in order to deserialize it. That assembly is not in the same folder as the mspec EXE, so it fails. If I copied my assembly into the same folder as mspec, it works fine.
What I still don't understand is why ReSharper and TD.Net can run the test just fine? Do they not use mspec.exe to actually run the tests?
.net - .net 中流行哪些 BDD 框架?
我最近开始涉足 BDD,并认为它很有希望作为一种让利益相关者在我们作为开发人员为他们创建的应用程序中获得回声的方式。你最喜欢的 BDD 框架是什么,为什么?
unit-testing - 使用模拟框架和 MSPEC 时,您在哪里设置存根
我对使用 MSpec 比较陌生,随着我编写越来越多的测试,很明显可以减少重复,根据Rob Conery 的文章,您经常必须使用基类进行设置
我很高兴使用 AssertWasCalled 方法来验证我的期望,但是您在哪里设置存根的返回值,我发现在注入我的依赖项的基类中设置上下文很有用,但是(我认为)意味着我需要在因为感觉委托中设置我的存根。
我错过了更好的方法吗?
nunit - 将 MSpec 与 MBUnit 一起使用?
有谁知道是否可以将 MSpec 与 MBUnit 一起使用而不是 NUnit?Gallio 在使用 MSpec 时似乎忽略了我所有的测试?
asp.net-mvc-2 - 有或没有 nunit 的 mspec 更好吗?
我在一些博客和讨论中看到 mspec 与 nunit 一起使用。事实上,我在网上看到的大多数示例都展示了 mspec 与某种 nunit 依赖或集成。我的团队正在尝试在新的 ASP.NET MVC2 项目中使用不带 nunit 的 mspec。我们还没有处于规范编写阶段,所以我不知道什么更好。你对此有何经验?将 mspec 与 nunit 一起使用有什么好处吗?没有?
c# - 测试大型状态机有哪些策略?
我继承了一个大型且相当复杂的状态机。它有 31 种可能的状态,都是真正需要的(大业务流程)。它有以下输入:
- 枚举:当前状态(所以 0 -> 30)
- 枚举:来源(目前只有 2 个条目)
- 布尔值:请求
- 布尔值:类型
- 枚举:状态(3 个状态)
- 枚举:处理(3 个状态)
- 布尔值:已完成
将其分解为单独的状态机似乎不可行,因为每个状态都是不同的。我为最常见的输入编写了测试,每个输入一个测试,所有输入都保持不变,除了状态。
没有人完全确定每个状态和一组输入的输出应该是什么。我已经开始为它编写测试。但是,我需要编写类似4320次测试(30 * 2 * 2 * 2 * 3 * 3 * 2)的东西。
您对测试状态机有什么建议?
编辑:我正在考虑所有建议,当我找到一个最有效的答案时会标记答案。
unit-testing - 同时适用于 xunit 和 mspec 的 Reharper 运行器插件
我已成功使用 Resharper 4.5 运行器在 vs2008 中进行 xunit 测试。现在我想尝试 MSpec,我想为 MSpec 使用 Resharper 4.5 运行器。但是我都安装了它们在启动 Visual Studio 时收到一条错误消息,即无法加载插件,因为已经加载了同名的插件。
是否可以同时加载两个插件?
c# - 测试 DefaultModelBinder 时出现 NullReferenceException
我正在使用 BDD/TDD 技术开发一个项目,并且我正在尽最大努力坚持到底。我刚刚遇到的一个问题是对 DefaultModelBinder 进行单元测试。我正在使用 mspec 编写我的测试。
我有一个这样的类,我想绑定到:
这是我构建规范上下文的方式。我正在构建一个假表单集合并将其填充到 bindingContext 对象中。
最后,当我从我的一个规范中执行 .BindModel() 时,我的规范引发了一个空引用异常:
任何线索可能是什么?
如果需要,请随时向我询问更多信息。我可能认为某些事情是理所当然的。
nunit - 是否可以在单个项目中进行 MSpec 和 NUnit 测试?
我有一个使用 NUnit 的单元测试项目。当我将 mspec (machine.specifications) 程序集添加到引用中时,ReSharper 和 TestDriven.Net 都停止运行 NUnit 测试并且只运行 mspec 测试。
有没有一种方法或设置允许 NUnit 和 mspec 测试共存并使用 R# 和 TD.Net 测试运行器在同一个项目中运行?