Cucumber CLI停止,没有任何错误

时间:2017-06-01 12:02:13

标签: java junit jmeter cucumber cucumber-jvm

我试图找到一种方法将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(" Print")不会在控制台中打印出来。

为什么它会在没有任何异常的情况下停止?由于这个问题,在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  

提前感谢您的回答!

1 个答案:

答案 0 :(得分:0)

似乎Cucumber核心jar中有一个System.exit(0)。

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

预计它应该关闭。我们可以使用Cucumber核心的run方法代替。