【问题标题】:Run TestNG single test from one Group从一个组运行 TestNG 单个测试
【发布时间】:2012-08-24 06:57:56
【问题描述】:

在 testng.xml 中,我包含了几个用于分组的测试类。在测试类中,我传递了一些参数和组名:

@Parameters({"excelName", "excelTabName"})
@BeforeClass(alwaysRun=true)
public void setup(){/*Setup code here*/}

@Test(groups={"security"})
public void searchUser() {/*Test code here*/}

如果我禁用除我想要运行的测试类名称之外的所有测试类名称,我会使用 mvn -Dgroup=groupName test 之类的 maven 命令。它会启动 testng.xml 中未注释的测试类

我希望在 testng.xml 中启用所有这些测试类,并且仍然希望在需要时只运行一个测试。任何建议将不胜感激。

【问题讨论】:

    标签: maven testng


    【解决方案1】:

    看起来你只需要指定运行时要执行的方法

    <test name="MyTest">
      <classes>
        <class name="TestClass">
          <methods>
            <include name="searchUser" />
          </methods>
        </class>
      </classes>
    </test>
    

    这将只加载测试方法searchUser() 执行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      相关资源
      最近更新 更多