Does new JUnit 4.8 @Category render test suites almost obsolete?

Posted by grigory on Stack Overflow See other posts from Stack Overflow or by grigory
Published on 2010-04-23T11:41:50Z Indexed on 2010/04/23 11:43 UTC
Read the original article Hit count: 209

Given question 'How to run all tests belonging to a certain Category?' and the answer would the following approach be better for test organization?

  1. define master test suite that contains all tests (e.g. using ClasspathSuite)
  2. design sufficient set of JUnit categories (sufficient means that every desirable collection of sets is identifiable using one or more categories)
  3. define targeted test suites based on master test suite and set of categories

For example:

  • identify categories for speed (slow, fast), dependencies (mock, database, integration), function (), domain (
  • demand that each test is properly qualified (tagged) with relevant set of categories.
  • create master test suite using ClasspathSuite (all tests found in classpath)
  • create targeted suites by qualifying master test suite with categories, e.g. mock test suite, fast database test suite, slow integration for domain X test suite, etc.

My question is more like soliciting approval rate for such approach vs. classic test suite approach. One unbeatable benefit is that every new test is immediately contained by relevant suites with no suite maintenance. One concern is proper categorization of each test.

© Stack Overflow or respective owner

Related posts about junit

Related posts about junit4