问题
I have my Cucumber Runner class as shown below and i need to call and run this runner class through gradle so that in turn it executes my stepdefinition / tests as we do it in normal cucumber project
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeSuite;
import com.inspire.brands.helper.reporter.ReporterUtil;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(features = { "classpath:featurefile" }, glue = { "classpath:com.inspire.brands.test.stepdefinition",
"classpath:com.inspire.brands.helper" }, plugin = { "pretty", "json:target/InspireBrands.json",
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" }, monochrome = true, tags = "@Api")
//tags = { "@Api","@UI8876"})
public class InspireBrandsTestRunner extends AbstractTestNGCucumberTests {
@AfterClass(alwaysRun = true)
public static void writeExtentReport() {
ReporterUtil.archiveReport();
}
/*
* @Override
*
* @DataProvider(parallel = true) public Object[][] scenarios() { return
* super.scenarios(); }
*/
}
But i dont want to do it by task Cuumber as shown below.
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty',
'--plugin', 'json:target/InspireBrands.json',
'--plugin', 'com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:Report',
'--glue','com.inspire.brands.test.stepdefinition',
'src/test/resources','src/main/java','src/main/java/com/inspire/brands/helper',
'--tags', '@Api'
]
}
}
}
来源:https://stackoverflow.com/questions/63745230/i-need-to-have-an-gradle-task-to-execute-my-cucumber-runner-class-and-execute-cu