6

I am using cucumber for ui testing written in java. I am trying to implement the cucumber plugin for rerunning failed scenarios, and created a second class to be the runner for those scenarios:

first class

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        strict = true,
        tags = {"@lakeisha"},
        features = ".",
        format = {"html:target/cucumber", "json:target/cucumber.json"},
        plugin = {
                "pretty", "html:target/cucumber-reports",
                "json:target/cucumber.json",
                "rerun:src/test/resources/rerun.txt" //Creates a text file with failed scenarios
        })
public class RunCukeTestsIT extends BaseCucumberRunner {
}

second class:

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        tags = {"@lakeisha"},
        features = "@src/test/resources/rerun.txt", //Cucumber picks the failed scenarios from this file
        format = {"html:target/cucumber", "json:target/cucumber.json"}
)
public class ReRunCukeTestsIT extends BaseCucumberRunner{

}

and i am running the tests using

mvn clean verify -Dcucumber.options=" --tags @lakeisha"

the problem is that running it through terminal doesn't seem to generate anything in the rerun.txt, but running it through IJ does. I also tried putting the plugin into Dcucumber.options portion of command, to no avail . Help much appreciated!

1ak31sha
  • 501
  • 7
  • 18
  • I can attach more of the log if needed, but see here the first line after TESTS shows me its trying to run the ReRun:------------------------------------------------------- T E S T S ------------------------------------------------------- None of the features at [@src/test/resources/rerun.txt] matched the filters: [@lakeisha] Running com.thomsonreuters.grc.accelus.wc1.ui.ReRunCukeTestsIT None of the features at [@src/test/resources/rerun.txt] matched the filters: [@lakeisha] – 1ak31sha Dec 08 '17 at 16:17
  • There is a parameter called 'runOrder' you can specify to change the default to alphbetic, reversealphabetic etc etc. Have a look -- http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#runOrder and http://www.xinotes.net/notes/note/1840/. Just a guess, if you rename ReRun... to RunRe... it may work, maybe... – Grasshopper Dec 08 '17 at 17:31
  • 1
    thanks Grasshoper. ive uncovered an issue. it seems that when running the command i posted, the rerun plugin does not even work. i tried adding the rerun plugin inside the Dcucumber.options, but still it is not running the plugin. i can tell because nothing is logged out and nothing get written to the rerun.txt. it works perfect thru intelliJ though...any ideas? – 1ak31sha Dec 12 '17 at 21:59
  • 1
    I may need to raise a new issue for this since its a different issue now – 1ak31sha Dec 12 '17 at 22:00
  • you mention nothing is written in the rerun.txt, then the rerun should not happen. Does the intellij one writes something to the rerun.txt. Maybe switch the rerun txt to another folder - https://stackoverflow.com/questions/21334207/rerunning-failed-cucumber-tests-using-cucumber-jvm#comment43259120_27402055 – Grasshopper Dec 13 '17 at 02:49
  • yes, running it thru intelliJ does add the failed cases to the rerun.txt. i dont see why changing the folder would do anything but i could give it a quick try – 1ak31sha Dec 13 '17 at 14:10
  • Can you check IJ is adding something else to the execution command as well? It may be possible you are missing some params in command line – Tarun Lalwani Dec 20 '17 at 14:16
  • How can i check that? IJ allows you to specifiy a class to run, but I dont know any parameter for mvn to specify the class. – 1ak31sha Dec 20 '17 at 20:02

0 Answers0