JUnit Annotations are not run while executing Gradle Cucumber Task

38 views
Skip to first unread message

Ansar S N

unread,
Jun 18, 2019, 5:04:04 AM6/18/19
to Cukes

Hello Team,

 

I badly need your help to resolve one issue that I am facing

 

I have a Gradle Cucumber Framework set up. In my TestRunner Class I have below code

 

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:target/cucumber-reports", "json:target/cucumber-reports/Cucumber.json", "junit:target/cucumber-reports/Cucumber.xml",},
       
features = {"src/test/resources"}, glue = {"com.healthcheck.services.StepDefenitions"})
public class TestRunner {

   
@AfterClass
   
public static void tearDown() {
        System.
out.println("Inside @AfterClass");
       
System.out.println(Base.resultList);
       
Base.buildReportAndSendToSlack(Base.env_test, Base.resultList, Base.failedScenariosMap);
   
}


}

 

 

When I run from the IntelliJ, (Run TestRunner ) the J Unit AfterClass is being executed whereas when I run the Gradle task (task in build.gradle file as below) from command line, AfterClass is not executed.

 

task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main =
"cucumber.api.cli.Main"
           
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
           
args = ['--plugin', 'pretty', '--plugin', 'html:target/cucumber-reports', '--plugin', 'json:target/cucumber-reports/Cucumber.json', '--plugin', 'junit:target/cucumber-reports/Cucumber.xml', '--glue', 'com.healthcheck.services.StepDefenitions', 'src/test/resources/com/healthcheck/services/Features']
        }
    }
}

 

It would be of great help if you could extend your help to resolve this issue

 

Thanks

Ansar

 

Reply all
Reply to author
Forward
0 new messages