Tuesday, December 8, 2009

JUnit 4.8.1 is released

JUnit 4.8's category support had a glaring error in the javadoc (CategoryType was a quickly-deleted design decision that lived on in the documentation), and in the implementation (Class-level annotations were not trickled down to methods). 4.8.1 fixes this:


Release notes


Javadoc

Download

Tuesday, December 1, 2009

JUnit 4.8 is released

JUnit 4.8 has been released. The primary new feature is preliminary support for Categories. For more information, see the release notes and javadoc, and then download!

Saturday, November 14, 2009

Categories in JUnit 4.8

This is from the tests for the upcoming JUnit 4.8 release.  It's the simplest-to-implement framework we could find for labelling tests with named categories, and running only tests with a given label.


public interface SlowTests extends CategoryType {

}

public static class A {
@Test
public void a() {
fail();
}

@Category(SlowTests.class)
@Test
public void b() {
}
}

@Category(SlowTests.class)
public static class B {
@Test
public void c() {

}
}

public static class C {
@Test
public void d() {
fail();
}
}

@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses( { A.class, B.class, C.class })
public static class SlowTestSuite {
}