【问题标题】:The Cucumber CLI stops without any errorCucumber CLI 停止,没有任何错误
【发布时间】:2017-06-01 12:02:13
【问题描述】:

我正在尝试找到一种将 JUNIT 测试方法与 Cucumber 集成以用于 JMeter 负载测试的方法。

我不知道为什么它没有执行完整的@Test 方法。为什么它毫无例外地停止。

下面是代码,

@Test
public void runTest() throws Throwable {

    try {
        String[] getRequest = GetRequest.testValuesReturn();
        Main.main(new String[]{"-g", "com.sanity.step.definition","-t", "@" +getRequest[1], "C:/Users/IBM_ADMIN/Documents/Automation/Performance Testing/PerformanceTesting/MyFeature.feature"});
        System.out.println("Print");
    } catch (Exception e) {
        e.printStackTrace();
    }
}    

测试一直运行到功能文件中定义的最后一步。下面是特征文件和最后一种方法。

When Start the performance Test
When Open the Inventory Page
When Click on Seamless Switch

最后一个方法,

 @When("^Click on Seamless Switch$")
public void Seamless_Switch() throws Throwable {    
    driver.baseDriver.findElement(By.id("seamlessSwitchButton")).click();
    log.info("Seamless switch is clicked");
    System.out.println("Click on Seamless Switch");
}

在“点击无缝切换”之前一直打印。但是@Test 注释方法(“打印”)中的 syso 不会打印在控制台中。

为什么它毫无例外地停止了?由于这个问题,在 JMeter 中,我什至在线程完成之前收到以下错误,

 2017/06/01 13:40:31 INFO  - jmeter.reporters.ResultCollector: Shutdown hook started 
 2017/06/01 13:40:31 INFO  - jmeter.reporters.ResultCollector: Shutdown hook ended  

提前感谢您的回答!

【问题讨论】:

  • 我不知道为什么它在最后打印这个 "[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[ 0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[ 0m "

标签: java junit jmeter cucumber cucumber-jvm


【解决方案1】:

Cucumber core jar 里面好像有 System.exit(0)。

public static void main(String[] argv) throws Throwable {
        byte exitstatus = run(argv, Thread.currentThread().getContextClassLoader());
        System.exit(exitstatus);
    }

预计它应该关闭。我们可以改用 Cucumber core 的 run 方法。

【讨论】:

    猜你喜欢
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 2020-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多