【问题标题】:Run single TestNG test with maven by using testng.xml使用 testng.xml 使用 maven 运行单个 TestNG 测试
【发布时间】:2016-06-06 14:29:22
【问题描述】:

我在参数化的testng.xml 中定义了我的测试。我使用 Failsafe 插件并使用mvn verify 运行我的测试。整个套件被执行。

如果我必须从我的testng.xml 套件中只运行一个测试怎么办?我希望使用这些参数,但我只想从命令行运行一个测试。

maven参数:

-Dit.test=CheckoutIT#testOrderId

因为没有testng.xml,maven直接运行测试不行,参数没有绑定,测试会被忽略。

有办法吗?一种解决方法是创建一个只有一个测试的临时套件 xml,但它不能成为解决方案......

最好的问候罗伯特

【问题讨论】:

  • 你想在xml的testtag中执行测试吗?

标签: java xml maven testng


【解决方案1】:

根据测试文档:

The command line flags that specify what tests should be run will be ignored if you also specify a testng.xml file, with the exception of -includedgroups and -excludedgroups, which will override all the group inclusions/exclusions found in testng.xml.

另一种解决方案是将侦听器添加到您的 maven 目标中,它将解析您的 testng.xml 并获取测试参数以将它们应用于您当前的测试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-14
    • 2019-05-05
    • 2017-06-17
    • 2018-01-31
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多