【问题标题】:Why doesn't nUnit execute my SpecsFor.Mvc tests?为什么 nUnit 不执行我的 SpecsFor.Mvc 测试?
【发布时间】:2016-03-11 08:25:41
【问题描述】:

我正在尝试使用SpecsFor.Mvc 实施端到端测试。我实现了以下测试:

namespace Features
{
    class AddEvents
    {

        public class when_a_user_adds_an_event: SpecsFor<MvcWebApp>
        {
            protected override void Given()
            {
                SUT.NavigateTo<HomeController>(c => c.Index());
            }
            protected override void When()
            {

                SUT.Browser.FindElementById("btn-add-event").Click();
                SUT.FindFormFor<Event>()
                    .Field(f => f.Name).SetValueTo("Alex")
                    .Field(f => f.Date).SetValueTo("01/01/2013")
                    .Submit();
            }

            [Test]
            public void then_event_should_be_added()
            {
                Assert.Fail();
            }
        }
    }
}

问题是,nUnit 没有发现这个测试并报告它没有找到任何测试。我有以下设置:

  • nunit-console 运行器版本 3.2
  • Visual Studio nUnit3 测试适配器版本 3.0.8.0(均未找到测试)
  • nUnit 版本 3.2.0
  • 规格为 4.4.0.0 版
  • Specsfor.Mvc 是版本 3.4.0.0
  • 所有项目均使用 .Net 4.6 构建

知道为什么测试运行者会忽略此测试吗?

【问题讨论】:

  • 您是否缺少课程中的 [TestFixture] 属性?这会在嵌套类when_a_user_adds_an_event里面。
  • 这不是问题,因为 SpecsFor 基类有一个 [TestFixture] 属性。

标签: .net asp.net-mvc nunit integration-testing


【解决方案1】:

报告了与 SpecsFor.MVC 相关的 NUnit 问题,请参阅 https://github.com/nunit/nunit/issues/1277

据我们(nunit 人)所知,SpecsFor 不支持 NUnit 3.0。然而,这是基于对他们代码的非常粗略的检查。我们没有人真正熟悉它。

坦率地说,除非有对 SpecsFor 有深入了解的人提出建议,否则问题不会有太大变化。

【讨论】:

  • 感谢您的回答,在 SpecsFor 问题跟踪器 (github.com/MattHoneycutt/SpecsFor/issues/87) 中也有相应的问题,它显示了我遇到的问题:Specsfor.Mvc Nuget package has a dependency to nUnit 3.0但不支持它 - 它需要 nUnit 2.x。
  • Charlie 是正确的,SpecsFor 不支持 NUnit 3.0。它实际上取决于 NUnit 2.x,而不是 3.0。我会更新 NuSpec,这样一有机会就不会让你升级到 NUnit 3.0...
猜你喜欢
  • 1970-01-01
  • 2011-12-28
  • 1970-01-01
  • 2020-11-07
  • 2014-08-14
  • 2017-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多