Search code examples
javajunitjmetercucumbercucumber-jvm

The Cucumber CLI stops without any error


I'm trying to find a way to Integrate JUNIT test methods with Cucumber to use in JMeter Load testing.

I'm clueless on why it's not executing the complete @Test method. Why it's stopping without any exceptions.

Below is the code,

@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();
    }
}    

The test runs until the last step defined in the feature file. Below is the feature file and last method.

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

And the last method,

 @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");
}

It's printing until "Click on Seamless Switch". But the syso in @Test annotated method ("Print") is not printed in the console.

Why is it stopping without any exception? Because of this issue, in JMeter, I'm getting the following errors before even completion of the thread,

 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  

Thanks in advance for your answers!


Solution

  • It seems that there's a System.exit(0) in the Cucumber core jar.

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

    It's expected that it should close. We can use the run method of Cucumber core instead.