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

More flexible Categories implementation (with suggested implementation) #363

Open
ahochsteger opened this issue Nov 19, 2011 · 4 comments
Open

Comments

@ahochsteger
Copy link

I would need the possibility to annotate test methods with different categories and then scan the whole classpath for matching tests:

/* MyTestSuite.java */
/** MyTestSuite runs all slow tests, excluding all test which require a network connection. */
@RunWith(FlexibleCategories.class)
@ExcludeCategory(OnlineTestCategory.class)
@IncludeCategory(SlowTestCategory.class)
@TestScanPackage("my.package")
@TestClassPrefix("")
@TestClassSuffix("Test")
public class MyTestSuite {
}

This would be an example test class:

/* SampleTest.java */
public class SampleTest {
    @Test
    @Category({OnlineTestCategory.class, SlowTestCategory.class})
    public void onlineAndSlowTestCategoryMethod() {
    }

    @Test
    @Category(OnlineTestCategory.class)
    public void onlineTestCategoryMethod() {
    }

    @Test
    @Category(SlowTestCategory.class)
    public void slowTestCategoryMethod() {
    }

    @Test
    public void noTestCategoryMethod() {
    }
}

On my blog I've described a solution that is working for me:
http://highstick.blogspot.com/2011/11/howto-categorize-junit-test-methods-and.html

@ahochsteger
Copy link
Author

@dsaff
Copy link
Member

dsaff commented Oct 10, 2013

Categories support has had some improvements in the last 2 years. I think that the current implementation of Categories, plus http://johanneslink.net/projects/cpsuite.jsp, could do what is asked here. Let me know what would be missing.

@shri046
Copy link

shri046 commented Dec 1, 2014

Are there any plans to bring the two together in near future? I have a similar need with my test suite containing 200+ test classes. Keeping up with the @SuiteClasses becomes a real hassle. As mentioned a combination of categories and cpsuite definitely works, but is there any specific reason as to why we need a dependency on a third party project to achieve this?

Just looking for some general roadmap/direction before I pull in the third party dependency in to our project.

@marcphilipp
Copy link
Member

At the moment there are no concrete plans to bring the two together. Most IDEs and build tools have there own implementation for collecting test classes, though. We would like to provide something that renders those unnecessary. However, that's a big effort and we didn't get to it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants