【问题标题】:Not able to run TestNG programmatically (Not able to create executable JAR)无法以编程方式运行 TestNG(无法创建可执行 JAR)
【发布时间】:2020-04-17 20:32:32
【问题描述】:

我想从 selenium testNg 代码创建一个可执行的 jar

 import org.testng.TestNG;
import com.test.Utility.ExtentReporterNG;

public class TestRunner {
    static TestNG testNg;
    public static void main(String[] args) {
        ExtentReporterNG ext = new ExtentReporterNG();
        TestNG testNg = new TestNG();
        testNg.setTestClasses(new Class[] { LoginTest.class });
        testNg.addListener(ext);
        testNg.run();
    }
}

它在 LoginTest 类中包含 3 个测试用例,但在执行时出现以下错误:

================================================ 命令行套件 运行的测试总数:3,通过:0,失败:0,跳过:3

配置失败:1,跳过:1

【问题讨论】:

    标签: java selenium selenium-webdriver testng executable-jar


    【解决方案1】:

    替换你的代码行:

    testNg.addListener(ext);
    

    替换为:

    testNg.addListener((ITestNGListener)ext);
    

    它会正常工作

    注意:

    我假设您在实现 IReporter 的 ExtentReporterNG 类中编写报告逻辑

    【讨论】:

      猜你喜欢
      • 2017-08-19
      • 2023-03-14
      • 1970-01-01
      • 2018-07-21
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2017-08-03
      相关资源
      最近更新 更多