login
Blurts on the Art of Software Development

Today | RSS | RDF | Atom | Other Tags
Categories : All | All | CI | .NET | General | Humour | Java | Personal | Reviews | Ruby | SW Eng

A couple of thought provokers for the aspiring great manager:

Speaking of upcoming conferences this Fall, I just remembered Google's conference on testing in London, September 7-8th. It sounds like a mighty interesting conference for professional test engineers.

Permalink
JUnit 4 trivia
Test suites using annotations

It seems that not that many developers migrating to JUnit 4 are aware of the replacement for the old way of building suites--using the static suite() method and the junit.framework.TestSuite class--I decided to blog a simple example for Google's indexing hamsters to grab hold of.

Here we go:

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
 
@RunWith(Suite.class)
@Suite.SuiteClasses({
  TestCalculatorAddition.class,
  TestCalculatorSubtraction.class,
  TestCalculatorMultiplication.class,
  TestCalculatorDivision.class
})
public class CalculatorSuite {
    // the class remains completely empty, 
    // being used only as a holder for the above annotations
}

The above class is a simple placeholder for the suite annotations, not containing any other functionality as such. The key is in the @RunWith annotation, which tells the JUnit 4 test runner to use the org.junit.runners.Suite class for running this particular class. The @Suite annotation, on the other hand, tells the Suite runner which test classes to include in this suite and in which order.

I hope this helps folks out there since it doesn't seem to be documented too well in junit.org.