Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReRun failing tests does not record feature data properly #890

Closed
karimnabli opened this issue Jul 28, 2015 · 11 comments
Closed

ReRun failing tests does not record feature data properly #890

karimnabli opened this issue Jul 28, 2015 · 11 comments

Comments

@karimnabli
Copy link

To reproduce this behave I will provide the project structure:
Maven Project Name: example-cucumber
the Pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>example.cucumber</groupId>
    <artifactId>example-cucumber</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>example-cucumber</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cucumber.version>1.2.2</cucumber.version>
        <cucumber.tags>--tags ~@skip</cucumber.tags>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>2.4.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <version>2.18.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <version>2.18.1</version>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>autoTest</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <systemProperties>
                                <cucumber.options>${cucumber.tags}</cucumber.options>
                            </systemProperties>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

The structure:
src/test/java[example.cucumber]: contain integration Test and mapping class
ExampleMapping.java:

package example.cucumber;
import static org.junit.Assert.assertEquals;

import java.net.URISyntaxException;

import com.jayway.restassured.RestAssured;
import com.jayway.restassured.response.Response;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
/**
 * @author nablik
 *
 */
public class ExampleMapping {

    private Response response;

    @Given("^the user send a get request to (.+)")
    public void setBaseUrl(String baseUrl) throws URISyntaxException{
        this.response = RestAssured.when().get(baseUrl);
    }

    @Then("^verify that the response code is equal to (.+)")
    public void verifyStatusCode(int statusCode){
        assertEquals(response.getStatusCode(), statusCode);
    }
}

TestExampleCucumberIT.java: test runner that will perform the first test execution and record data in target/rerun.txt

package example.cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = true, glue = { "example.cucumber" }, 
features = { "src/test/features" }, 
plugin = { "json:target/cucumber-report-composite.json", "pretty",
        "html:target/cucumber/","rerun:target/rerun.txt" }, 
tags = { "~@skip" })
public class TestExampleCucumberIT {

}

the _TestExampleCucumberIT.java will perform the second test execution (as maven will run all IT class, the second one start with _ so it will be run after the previous test bulk)

package example.cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = true, 
glue = { "example.cucumber" }, 
features = { "@target/rerun.txt" }, 
plugin = { "json:target/cucumber-report-composite.json", "pretty",
        "html:target/cucumber/"})
public class _TestExampleCucumberIT {
}

Feature files are stored within the following structure :

src/test/features/Test0.feature
src/test/features/group1/Test1.feature
src/test/features/group2/Test2.feature

The tests are actually very basic
Test0.feature:

Feature: Test_0 example
Scenario: test 0_1
Given the user send a get request to http://www.google.com
Then verify that the response code is equal to 200

Scenario: test 0_2
Given the user send a get request to http://www.google.ie
Then verify that the response code is equal to 200

Scenario: test 0_3
Given the user send a get request to http://www.google.fr
Then verify that the response code is equal to 200

the second one :

Feature: Test_1 example
Scenario: test 1_1
Given the user send a get request to http://www.yahoo.com
Then verify that the response code is equal to 200

Scenario: test 1_2
Given the user send a get request to http://www.yahoo.fr
Then verify that the response code is equal to 2000

Scenario: test 1_3
Given the user send a get request to http://www.yahoo.it
Then verify that the response code is equal to 200

and the last one:

Feature: Test_2 example
Scenario: test 2_1
Given the user send a get request to http://www.google.es
Then verify that the response code is equal to 700

Scenario: test 2_2
Given the user send a get request to http://www.google.pt
Then verify that the response code is equal to 200

Scenario: test 2_3
Given the user send a get request to http://www.google.com
Then verify that the response code is equal to 400

Now run the following maven command:

mvn clean verify -PautoTest -Dcucumber.tags="--tags ~@skip"

the out put will be

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building example-cucumber 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ example-cucumber ---
[INFO] Deleting /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ example-cucumber ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nablik/Work/workspaces/wkspace1/example-cucumber/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ example-cucumber ---
[INFO] Compiling 1 source file to /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ example-cucumber ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nablik/Work/workspaces/wkspace1/example-cucumber/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ example-cucumber ---
[INFO] Compiling 3 source files to /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ example-cucumber ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ example-cucumber ---
[INFO] Building jar: /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/example-cucumber-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ example-cucumber ---
[INFO] Failsafe report directory: /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/failsafe-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running example.cucumber.TestExampleCucumberIT
Feature: Test_0 example

  Scenario: test 0_1                                           # Test0.feature:2
    Given the user send a get request to http://www.google.com # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200         # ExampleMapping.verifyStatusCode(int)

  Scenario: test 0_2                                          # Test0.feature:6
    Given the user send a get request to http://www.google.ie # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200        # ExampleMapping.verifyStatusCode(int)

  Scenario: test 0_3                                          # Test0.feature:10
    Given the user send a get request to http://www.google.fr # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200        # ExampleMapping.verifyStatusCode(int)
Feature: Test_1 example

  Scenario: test 1_1                                          # group1/Test1.feature:2
    Given the user send a get request to http://www.yahoo.com # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200        # ExampleMapping.verifyStatusCode(int)

  Scenario: test 1_2                                         # group1/Test1.feature:6
    Given the user send a get request to http://www.yahoo.fr # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 2000      # ExampleMapping.verifyStatusCode(int)
      java.lang.AssertionError: expected:<200> but was:<2000>
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.failNotEquals(Assert.java:834)
        at org.junit.Assert.assertEquals(Assert.java:645)
        at org.junit.Assert.assertEquals(Assert.java:631)
        at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
        at ✽.Then verify that the response code is equal to 2000(group1/Test1.feature:8)


  Scenario: test 1_3                                         # group1/Test1.feature:10
    Given the user send a get request to http://www.yahoo.it # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200       # ExampleMapping.verifyStatusCode(int)
Feature: Test_2 example

  Scenario: test 2_1                                          # group2/Test2.feature:2
    Given the user send a get request to http://www.google.es # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 700        # ExampleMapping.verifyStatusCode(int)
      java.lang.AssertionError: expected:<200> but was:<700>
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.failNotEquals(Assert.java:834)
        at org.junit.Assert.assertEquals(Assert.java:645)
        at org.junit.Assert.assertEquals(Assert.java:631)
        at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
        at ✽.Then verify that the response code is equal to 700(group2/Test2.feature:4)


  Scenario: test 2_2                                          # group2/Test2.feature:6
    Given the user send a get request to http://www.google.pt # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 200        # ExampleMapping.verifyStatusCode(int)

  Scenario: test 2_3                                           # group2/Test2.feature:10
    Given the user send a get request to http://www.google.com # ExampleMapping.setBaseUrl(String)
    Then verify that the response code is equal to 400         # ExampleMapping.verifyStatusCode(int)
      java.lang.AssertionError: expected:<200> but was:<400>
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.failNotEquals(Assert.java:834)
        at org.junit.Assert.assertEquals(Assert.java:645)
        at org.junit.Assert.assertEquals(Assert.java:631)
        at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
        at ✽.Then verify that the response code is equal to 400(group2/Test2.feature:12)


9 Scenarios (3 failed, 6 passed)
18 Steps (3 failed, 15 passed)
0m12.314s

java.lang.AssertionError: expected:<200> but was:<2000>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 2000(group1/Test1.feature:8)

java.lang.AssertionError: expected:<200> but was:<700>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 700(group2/Test2.feature:4)

java.lang.AssertionError: expected:<200> but was:<400>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 400(group2/Test2.feature:12)

Tests run: 27, Failures: 6, Errors: 0, Skipped: 0, Time elapsed: 12.469 sec <<< FAILURE! - in example.cucumber.TestExampleCucumberIT
Then verify that the response code is equal to 2000(Scenario: test 1_2)  Time elapsed: 0.011 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<2000>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 2000(group1/Test1.feature:8)

Scenario: test 1_2  Time elapsed: 0.011 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<2000>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 2000(group1/Test1.feature:8)

Then verify that the response code is equal to 700(Scenario: test 2_1)  Time elapsed: 0.001 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<700>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 700(group2/Test2.feature:4)

Scenario: test 2_1  Time elapsed: 0.001 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<700>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 700(group2/Test2.feature:4)

Then verify that the response code is equal to 400(Scenario: test 2_3)  Time elapsed: 0.001 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<400>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 400(group2/Test2.feature:12)

Scenario: test 2_3  Time elapsed: 0.002 sec  <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<400>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:645)
    at org.junit.Assert.assertEquals(Assert.java:631)
    at example.cucumber.ExampleMapping.verifyStatusCode(ExampleMapping.java:29)
    at ✽.Then verify that the response code is equal to 400(group2/Test2.feature:12)

Running example.cucumber._TestExampleCucumberIT
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE! - in example.cucumber._TestExampleCucumberIT
initializationError(example.cucumber._TestExampleCucumberIT)  Time elapsed: 0 sec  <<< ERROR!
java.lang.IllegalArgumentException: Neither found on file system or on classpath: Not a file or directory: /Users/nablik/Work/workspaces/wkspace1/example-cucumber/group1/Test1.feature, No resource found for: classpath:group1/Test1.feature
    at cucumber.runtime.model.CucumberFeature.loadFromFileSystemOrClasspath(CucumberFeature.java:82)
    at cucumber.runtime.model.CucumberFeature.loadFromRerunFile(CucumberFeature.java:66)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:201)
    at cucumber.api.junit.Cucumber.<init>(Cucumber.java:60)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


Results :

Failed tests:
  expected:<200> but was:<2000>
  expected:<200> but was:<2000>
  expected:<200> but was:<700>
  expected:<200> but was:<700>
  expected:<200> but was:<400>
  expected:<200> but was:<400>
Tests in error:
  _TestExampleCucumberIT.initializationError » IllegalArgument Neither found on ...

Tests run: 28, Failures: 6, Errors: 1, Skipped: 0

[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ example-cucumber ---
[INFO] Failsafe report directory: /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/failsafe-reports
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.219s
[INFO] Finished at: Tue Jul 28 01:25:05 IST 2015
[INFO] Final Memory: 17M/197M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project example-cucumber: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/nablik/Work/workspaces/wkspace1/example-cucumber/target/failsafe-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

and the rerun.txt

group1/Test1.feature:6 group2/Test2.feature:2:10

BUT IF we change manually the file as following:

src/test/features/group1/Test1.feature:6 src/test/features/group2/Test2.feature:2:10

the tests will be re-executed again.
The missing piece is the prefix src/test/feature
Honestly I don't know how to fix this.
I hope that anyone can help. At least to point me to the source of the problem so I can try to fix.

@aslakhellesoy
Copy link
Contributor

Try to put your feature files under src/test/resources/features rather than src/test/features.
Also, remove features = { "src/test/features" } from your annotation - you don't need to specify it at all.
Finally, please upgrade to 1.2.4 (1.2.2 should work too, but bugs should always be reported against the latest version).

@karimnabli
Copy link
Author

I will do that. Thanks million.

@karimnabli
Copy link
Author

Upgrade to 1.2.4 : Done
Change the feature files to be under resources: Done
Remove features = { "src/test/features" } does not solve any problem, it does not recognise any feature file, so I put it back.
run again: Exact same failure.
Hack again: pass.
I think there is a problem.

@brasmusson
Copy link
Contributor

Producing a rerun.txt for re-running failed scenarios works as intended when:

  • the feature files are loaded from the classpath (using features = { "classpath:<something>" } or not specifying the feature option - which means that feature files are loaded from the package of the runner class and its sub-packages)
  • the features option specifies the current directory (features = { "." })

Using the feature option to specify a directory path (like features = { "src/test/features" }), does not work. It is not a issue of the rerun formatter per se, it has to do with the fact the the uri for feature files that are sent to the formatters are either the full package path (when the feature files are loaded from the classpath), or the directory path from the directory specified in the features options. The listings above shows this as in:

Scenario: test 2_2                                          # group2/Test2.feature:6
                                                              ^^^^^^^^^^^^^^^^^^^^ the uri the formatters get

@nablik If you moved the feature files to:

src/test/resources/features/Test0.feature
src/test/resources/features/group1/Test1.feature
src/test/resources/features/group2/Test2.feature

you need to specify features = { "classpath:features" }, not specifying the features options at all will in your case result in that src/test/resources/example/cucumber will be searches for feature files, as your runner classes are in the package example.cucumber.

@karimnabli
Copy link
Author

clear now, I have not understood things as they should be.
Thanks, I will close the issue.

@sugatmankar
Copy link

Hi Nablik,

I tried your way. I am able to rerun successfully.

You just have to specify path while using command

mvn clean verify -PautoTest -Dcucumber.tags="src/test/features/ --tags ~@Skip"

Thanks a lot.

@ssvali
Copy link

ssvali commented May 6, 2017

Hi ,

I tried to rerun the failed scenario as mention above but i am getting the below error.

Running example.cucumber._TestExampleCucumberIT
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.006 sec <<< FAILURE! - in example.cucumber._TestExampleCucumberIT
initializationError(example.cucumber._TestExampleCucumberIT) Time elapsed: 0.005 sec <<< ERROR!
java.lang.IllegalArgumentException: Inconsistent filters: [~@Skip, 6]. Only one type [line,name,tag] can be used at once.
at gherkin.formatter.FilterFormatter.detectFilter(FilterFormatter.java:59)
at gherkin.formatter.FilterFormatter.(FilterFormatter.java:41)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:126)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:102)
at cucumber.runtime.model.CucumberFeature.loadFromFileSystemOrClasspath(CucumberFeature.java:73)
at cucumber.runtime.model.CucumberFeature.loadFromRerunFile(CucumberFeature.java:66)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:201)
at cucumber.api.junit.Cucumber.(Cucumber.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Results :

Failed tests:
expected:<200> but was:<2000>
expected:<200> but was:<2000>
expected:<200> but was:<700>
expected:<200> but was:<700>
expected:<200> but was:<400>
expected:<200> but was:<400>
Tests in error:
_TestExampleCucumberIT.initializationError » IllegalArgument Inconsistent filt...

Tests run: 28, Failures: 6, Errors: 1, Skipped: 0

[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! The file encoding for reports output files should be provid
ed by the POM property ${project.reporting.outputEncoding}.
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ rerunFailedTC ---
[INFO] Failsafe report directory: D:\AtWork\CucumberJVMParallelExecution\Rerun\rerunFailedTC\target\failsafe-reports
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! The file encoding for reports output files should be provid
ed by the POM property ${project.reporting.outputEncoding}.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.476 s
[INFO] Finished at: 2017-05-06T07:10:07+05:30
[INFO] Final Memory: 19M/170M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project rerunFailedTC: There are test failures.
[ERROR]
[ERROR] Please refer to D:\AtWork\CucumberJVMParallelExecution\Rerun\rerunFailedTC\target\failsafe-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@sugatmankar - It will be a great help if you can give a sample project or example to rerun the failed scenarios. Thanks a lot in advance.

@brasmusson
Copy link
Contributor

@ssvali
Copy link

ssvali commented May 10, 2017

@brasmusson Thank you very much

@yzerk
Copy link

yzerk commented Dec 6, 2017

Hi,
See #958

@lock
Copy link

lock bot commented Dec 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants