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

WildcardPatternSuite Allow searching from parent directory #16

Closed
shayfdna opened this issue May 23, 2017 · 9 comments
Closed

WildcardPatternSuite Allow searching from parent directory #16

shayfdna opened this issue May 23, 2017 · 9 comments

Comments

@shayfdna
Copy link

Hey, i want my 'tests' folder to be alongside my 'suits' folder.
and i can't "../**/*xTest.class". can you hero please ?

also i asked on stack overflow.
https://stackoverflow.com/questions/44127825/junit-suite-from-classpath-with-categories-support
thank you

@shayfdna
Copy link
Author

shayfdna commented May 23, 2017

to solve this i had to get a copy of the class 'WildcardPatternSuite' and rewrite the method 'getBaseDir' to:

private static File getBaseDir(Class<?> klass) throws InitializationError {
    String rootBuildPath = klass.getProtectionDomain().getCodeSource().getLocation().getFile();
    URL klassUrl = klass.getResource(klass.getSimpleName() + ".class");
    return new File(rootBuildPath);
}

@MichaelTamm
Copy link
Owner

Hi,

would you like to create Pull Request?

@shayfdna
Copy link
Author

shayfdna commented May 29, 2017

i would, but this resulting for 2 tests to fail. i don't have time to understand why,
here is my fix.
(i would love to use it, thank you )

WildcardPatternSuite.java.zip

@shayfdna
Copy link
Author

have you looked at it ?

@kevdowney
Copy link

+1 on this feature. Please submit a PR.

@MichaelTamm
Copy link
Owner

@shayfdna With your changes to getBaseDir(...) the method does no longer return the directory, where the suite class is located, but the test-classes directory.

I understand your intent, but this change would break all existing suite classes, which are inside some package and use the @WildcardPatternSuite annotation.

@shayfdna
Copy link
Author

shayfdna commented Jul 4, 2017

thanks Michal, for me parent directory of the test suite is not enough, since my project structure is complex and hierarchy is deeper then one folder

@MichaelTamm
Copy link
Owner

You can now* use: @SuiteClasses("../../../foo/**/*Test.class")

I.e. you can go as many levels up as you want (as long as all test classes are under the same test-classes directory).

  • now == now if you use HEAD else whenever I have time to publish a new release ;)

@MichaelTamm
Copy link
Owner

I released JUnit Toolbox 2.4 which includes the fix for this issue.

MichaelTamm added a commit that referenced this issue Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants