1

My service create an executable jar by gradle. When i create and run my jar (java -jar file.jar) i recive error:

no main manifest attribute, in "file.jar"

because i don't have main_class.

I created main method:

public static void main(final String[] args) throws Throwable {
String[] arguments = {"--plugin", "html:build/reports/cucumber", "src/test/resources/features", "--glue", "src/test/java/steps"};
cucumber.api.cli.Main.main(arguments);

}

and My program founds the features but doesn't found glue code.

Could someone help me with this problem? Thank you in advance.

P.R.S
  • 43
  • 3
  • 8

2 Answers2

0

The value for the glue option should be a java classpath. And the feature files should be the last option.

{"--plugin", "html:build/reports/cucumber", "--glue", "steps", "src/test/resources/features"}
Grasshopper
  • 8,908
  • 2
  • 17
  • 32
  • When I added this code the program the program still does not find the code. `3 Steps (3 undefined)` – P.R.S Jul 16 '17 at 19:34
  • What happens when you run the class containing the above command directly, outside of the jar file? – Grasshopper Jul 17 '17 at 04:29
  • When I moved folder with all steps and runed class with main method the app found glue code and features. – P.R.S Jul 17 '17 at 12:00
0

The below code worked for me to execute the cucumber tests from runnable jar with test frame work as TestNG.

Executing jar: java -jar ProductsAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar

import io.cucumber.core.cli.Main;
public static void main(String args[]) throws Throwable {
    try {
        Main.main(new String[] { 
    

        "-g","com.sadakar.cucumber.common",
        "-g","com.sadakar.cucumber.runner",
                    
        "classpath:features", 
        
        "-t","@SmokeTest",
        
                
        "-p", "pretty", 
        "-p", "json:target/cucumber-reports/cucumber.json", 
        "-p", "html:target/cucumber-reports/cucumberreport.html",
        
        "-m"
    }
    );
} catch (Exception e) {
        e.printStackTrace();
        System.out.println("Main method exception : " + e);
}
}
sadakar
  • 28
  • 9