1

In my cucumber project, whenever I execute my testrunner (using junit), it terminates without throwing any error before any test is executed but when I execute my feature file then all the tests get executed without any issue, why, where am I going wrong?

Following is my project structure:

 src
    |____main
    |
    |____test
         |___java
             |___features
             |   |___quotation.feature
             |___stepdefinitions
             |   |___quotation.java
             |___AppHooks
             |   |___ApplicationHooks.java
             |___testRunners
                 |___MyTestRunner.java

enter image description here

Following is my testrunner class (MyTestRunner.java):

package testRunners;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions( 
        features = "src/test/java/features/quotation.feature",
                  glue= {"stepdefinitions","AppHooks"},
                  plugin= {"pretty"}
        )
public class MyTestRunner {

}
           

enter image description here

user2044296
  • 504
  • 1
  • 7
  • 18
  • It seem the feature path isn't been recognized. Try to use "features = "classpath:/features/quotation.feature", and check if your feature file follows the pattern starting with the keywork Feature:. Also I recomend you to change the .feature files to resources folder because "src" is Source folder not feature folder. – Roberto Pegoraro Sep 27 '22 at 20:10
  • I tried it but no luck. Even moved the feature files folder to resource folder – user2044296 Sep 27 '22 at 20:41
  • Please check the following thread: [stackoverflow link](https://stackoverflow.com/questions/23900401/terminated-filename-java-application-c-program-files-java-jre8-bin-javaw-ex) – GabrielFethi Sep 28 '22 at 20:44
  • Thanks, but I was able to solve the issue by selecting junit 4 as testrunner, earlier I was using junit 5. Junit 5 was causing the issue. – user2044296 Sep 29 '22 at 12:35

1 Answers1

1

After trying everything I tried executing it through junit 4 and it worked, junit 5 was causing the issue. If anyone can throw light why it failed with junit 5 then that would be great..enter image description here

user2044296
  • 504
  • 1
  • 7
  • 18