简体   繁体   English

如何通过Visual Studio创建和运行NUnit / WebDriver测试套件?

[英]How do I create and run NUnit/WebDriver test-suites via Visual Studio?

I've recently moved from a Java-JUnit4-Webdriver environment to a C#-NUnit-Webdriver one. 我最近从Java-JUnit4-Webdriver环境转移到了C#-NUnit-Webdriver环境。

In Eclipse, I could create test-suites quickly by copying test classes into a test-suite class, and after minimal formatting, run them as JUnit tests. 在Eclipse中,我可以通过将测试类复制到测试套件类中来快速创建测试套件,然后以最小的格式将它们作为JUnit测试运行。 The JUnit test-suites used the pattern below: JUnit测试套件使用以下模式:

       package com.example.testsuites;

            import org.junit.runner.RunWith;
            import org.junit.runners.Suite;
            import org.junit.runners.Suite.SuiteClasses;

            import com.example.TestBase;
            import com.example.Test1;
            import com.example.Test2;
            import com.example.Test3;
            import com.example.Test12;
            import com.example.Test303;

            @RunWith(Suite.class)
            @SuiteClasses({Test1.class,
              Test2.class,
              Test3.class,
              Test12.class,
              Test303.class,
              })

            public class ExampleTestSuite extends TestBase {
         }

Is there an equivalent way to conveniently generate NUnit test-suite classes and then execute them in Visual Studio? 是否有等效的方法可以方便地生成NUnit测试套件类,然后在Visual Studio中执行它们?

I've been reading the NUnit documentation but can find no obvious equivalent. 我一直在阅读NUnit文档,但找不到明显的等效内容。 I know that with the NUnit GUI you can select tests to run via check-boxes but this does not create a permanent test-suite. 我知道,使用NUnit GUI可以选择要通过复选框运行的测试,但这不会创建永久的测试套件。 And that suites can be created by adding attributes/categories etc to individual tests but this doesn't appear as flexible as the method above. 可以通过向各个测试中添加属性/类别等来创建套件,但这并不像上面的方法那样灵活。

You can use NUnit Suite functionality: 您可以使用NUnit Suite功能:

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  private class AllTests
  {
    [Suite]
    public static IEnumerable Suite
    {
      get
      {
        ArrayList suite = new ArrayList();
        suite.Add(typeof(OneTestCase));
        suite.Add(typeof(AssemblyTests));
        suite.Add(typeof(NoNamespaceTestFixture));
        return suite;
      }
    }
  }
}

However, Suites are currently not displayed in the NUnit GUI. 但是,套件当前未显示在NUnit GUI中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在带有 C# 的 Visual Studio Code 中,如何在发布模式下运行 NUnit 测试? - In Visual Studio Code with C#, how do I run an NUnit test in Release mode? 如何从Visual Studio以调试模式运行NUnit? - How do I run NUnit in debug mode from Visual Studio? 如何使用NUnit在Visual Studio中强制最后一次运行测试 - How to force a test run last in visual studio using NUnit 如何在Visual Studio 2010中调试Nunit测试 - How to debug Nunit test in Visual Studio 2010 从Visual Studio中的MSTest或NUnit或控制台应用程序中运行Fitnesse测试 - Run fitnesse test out of MSTest or NUnit or console application in Visual Studio 如何使用MSBuild + bath与Selenium WebDriver一起运行NUnit测试? - How I can run my NUnit test with Selenium WebDriver using MSBuild + bath? 如何在命令行中运行通常在Visual Studio测试资源管理器中运行的.cs测试? - How do I run .cs tests that I normally run in the Visual Studio Test Explorer, in the command line? 如何为Nunit CollectionAssert测试创建IComparer? - How do I create an IComparer for a Nunit CollectionAssert test? 单元测试,NUnit或Visual studio? - Unit test, NUnit or Visual studio? 如何在仍然引用 NUnit 的同时使我的 Visual Studio 2017 项目不是测试项目 - How can I make my visual studio 2017 project NOT a test project while still referencing NUnit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM