xavier
xavier

Reputation: 177

Specific tests from a Suite Category

Is it possible to run only some methods (not all) from a test case in Junit4 (Eclipse)? I have 2 test cases and I want to implement a test suite which contains all the methods from one test case (I did that by adding the @Category annotation to all the tests from the first test case and then in the suite i used @IncludeCategory) and some methods from the second one.

Thank you!

Upvotes: 2

Views: 77

Answers (1)

Jakub Ch.
Jakub Ch.

Reputation: 3717

Yes, it is possible. Just put the @Category annotation containing the same marker:

  • on class level - on a class from which all methods should be included in a suite.
  • on method level - annotate selected methods within a class when not all of them should be included in a suite.

...and include that category within your suite.

I believe that first SlowTestSuite class from an example in Category documentation shows the situation you've asked about - it runs all tests from B and only some from A.

Upvotes: 0

Related Questions