Hello All, I have created one task to rerun failed...
# community-support
v
Hello All, I have created one task to rerun failed cucumber test cases. In this task it should run the particular scenarios mentioned in the rerun.txt file. In sample project where definitions for scenarios are part of project itself then it is working fine but in my case the definitions are part of one of the dependency jar and because of that when I try to execute the task it gives error as Undefined scenarios. So I'm looking for a way to pass the required dependency jar as part of classpath so that it should be able to find the definitions through my code snippet. Code Snippet:
Copy code
tasks.register('cucumberRerunFailed') {
  onlyIf {
    def rerunTxtFile = file('build/rerun.txt')
    return rerunTxtFile.exists() && rerunTxtFile.text.trim() != ''
  }

  doLast {
    try {
      javaexec {
        main = "io.cucumber.core.cli.Main"
        classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
                args = ['--plugin', 'json:build/reports/cucumber-tests/cucumber-rerun-report.json',
                '--glue', 'com.xyz.microservice.core.test.cucumber',
                '@build/rerun.txt']
      }
    } catch (Exception e) {
      println("cucumberRerunFailed task failed, but build will continue. Result: " + e)
    }
  }
}

configurations {
  cucumberRuntime {
    extendsFrom testImplementation
  }
}
Required dependency in classpath: testImplementation ("com.xyz:xyz-microservice-test-framework") Thanks in Advance, Vishal