无法使用 VS Express 2012 for Web、MVC4、WatiN 和 NUnit 查找或运行集成测试



我正在尝试让"Hello World"WatiN示例使用VS Express 2012 for Web、MVC4、WatiN和NUnit。

但是,Visual Studio似乎无法识别该测试。当我右键单击测试方法并单击"运行测试"时,除了重建(它是干净的)之外,什么都不会发生。在任何时候,"测试资源管理器"中都不会显示任何内容。

集成测试代码为:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using WatiN.Core;
namespace FootyStatMVC1.Tests
{
    [TestFixture]
    [RequiresSTA]
    public class UnitTest1
    {
        [Test]
        public void TestMethod1()
        {
            IE ie = new IE("http://www.google.com");
            ie.TextField(Find.ByName("q")).TypeText("WatiN");
            ie.Button(Find.ByValue("Google Search")).Click();
        }
    }
}

我已经使用nuget安装了NUnit和WatiN。我还添加了建议的配置代码

http://agilewarrior.wordpress.com/2010/07/02/getting-started-with-watin-nunit-and-mvc-net/

生成的配置文件名为app.config,如下所示:

<configuration>
  <appSettings>
  </appSettings>
  <connectionStrings></connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <!-- MSM integration testing aug 31st-->
  <configSections>
    <sectionGroup name="NUnit">
      <section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
    </sectionGroup>
  </configSections>
  <NUnit>
    <TestRunner>
      <!-- Valid values are STA or MTA (Others are ignored) -->
      <add key="ApartmentState" value="STA" />
    </TestRunner>
  </NUnit>
</configuration>

为什么Visual studio看不到测试?

提前感谢!

Mat

Visual Studio 2012不会识别NUnit单元测试夹具。它使用自己的Microsoft测试框架,类似于NUnit,但不同。

您使用的Express版本甚至无法识别Microsoft测试,因为Express版本中不包含测试运行程序。

最好是在VisualStudio之外使用NUnit测试运行程序。

遗憾的是,所有其他插入Visual Studio 2012的测试运行程序都无法使用Visual Studio 2012学习版,因为它也不允许使用插件。如果您希望在VisualStudio中使用众多集成测试运行程序中的一个,则必须升级。

最新更新