【问题标题】:How can I change Surefire Test Case name programatically using TestNG?如何使用 TestNG 以编程方式更改 Surefire 测试用例名称?
【发布时间】:2015-05-11 13:23:26
【问题描述】:

我一直在用 Surefire 试验一个问题。

我不知道如何以编程方式更改测试套件的名称和测试用例的名称。

现在我有了这个测试套件和这个测试用例名称:

INFO: Starting the test suite: [Surefire suite] ... 
INFO: Starting the test case: [Surefire test] ... 

如何将Surefire suiteSurefire test 更改为TestNG 测试名称和测试套件?我必须编辑 pom.xml 文件吗?

【问题讨论】:

  • 你是如何从 Surefire 运行测试的?调用xml还是直接测试?
  • 我以不同的方式做这件事。 XML,直接或通过 maven

标签: java maven testng maven-surefire-plugin


【解决方案1】:

【讨论】:

  • 请从链接中添加一些内容。
  • 在代码中:/** The default name for a suite launched from the maven surefire plugin */ public static final String DEFAULT_SUREFIRE_SUITE_NAME = "Surefire suite"; /** The default name for a test launched from the maven surefire plugin */ public static final String DEFAULT_SUREFIRE_TEST_NAME = "Surefire test"; private static class TestMetadata { private String testName = DEFAULT_SUREFIRE_TEST_NAME; private String suiteName = DEFAULT_SUREFIRE_SUITE_NAME; } // and further testName and suiteName not changed.
  • 或者更改库surefire-testng,更改为DEFAULT_SUREFIRE_SUITE_NAME DEFAULT_SUREFIRE_TEST_NAME,并可以从命令行设置示例。构建并安装修改后的库。就像我为自己所做的那样。
猜你喜欢
  • 1970-01-01
  • 2011-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多