I need to have an gradle task to execute my cucumber runner class and execute cucumber tets

匆匆过客 提交于 2021-01-29 06:39:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!