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

Running cucumber tests in Eclipse causes exception #259

Closed
remast opened this issue Mar 14, 2012 · 4 comments
Closed

Running cucumber tests in Eclipse causes exception #259

remast opened this issue Mar 14, 2012 · 4 comments

Comments

@remast
Copy link

remast commented Mar 14, 2012

Running cucumber tests in eclipse causes an exception because the *.feature files exist duplicated in the classpath. Eclipse puts all resources including the *.feature files in the classpath. Additionally the classpath contains the directory with the resources.
-> As a result two identical versions of the same *.feature files exist in the classpath.

This causes the following code in the FeatureBuilder to throw a CucumberException:

public void parse(Resource resource, List<Object> filters) {
    Formatter formatter = this;
    if (!filters.isEmpty()) {
        formatter = new FilterFormatter(this, filters);
    }
    Parser parser = new Parser(formatter);
    String gherkin = read(resource);

    String checksum = checksum(gherkin);
    String path = pathsByChecksum.get(checksum);
    if (path != null) {
        throw new CucumberException(String.format("Found the same source in %s and %s", path, resource.getPath()));
    }
    pathsByChecksum.put(checksum, resource.getPath());

Having two identical *.feature files on the claspath does no harm. So I suggest that's tolerated as long as both files have the same checksum. If desired a warning could be logged.

@aslakhellesoy
Copy link
Contributor

That code was written to fix #165.

Is eclipse copying .feature files from a source directory to a target directory? Why? If so, why are both the source and target directories on the classpath?

How do you suggest fixing this issue without breaking the fix for #165?

@remast
Copy link
Author

remast commented Mar 14, 2012

Why eclipse does that I have no clue. What I know is that given I have a maven project in eclipse with the directory layout:

  • src/test/resources which contains the *.feature files and is a source directory of the project
  • target/classes as directory where eclipse puts the compiled classes (and all resources including *.feature files)
    In that setting I end up with two identical feature files in the classpath.

For fixing #165 the md5 checksum was introduced. But can't we just ignore multiple feature files having the identical md5 checksum? So if there are 2 feature files on the classpath with identical md5 checksum only one of them is executed. If there are two feature files on the classpath having different md5 checksums a CucumberException is thrown. If I got it right this would not break #165.

@aslakhellesoy
Copy link
Contributor

@remast that sounds like a good approach

@lock
Copy link

lock bot commented Oct 25, 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 Oct 25, 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

2 participants