Skip to content

Commit

Permalink
Update JUnit version, improve ClassRule javadoc, update release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaff committed Jan 3, 2011
1 parent 8d26b45 commit b310cd5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 45 deletions.
2 changes: 1 addition & 1 deletion build.xml
Expand Up @@ -5,7 +5,7 @@
<property name="src" value="src/main/java" />
<property name="target" location="target" />
<property name="bin" location="${target}/main" />
<property name="version-base" value="4.9-SNAPSHOT-20100512-0041" />
<property name="version-base" value="4.9-RC1" />
<property name="version-status" value="" />
<property name="version" value="${version-base}${version-status}" />
<property name="dist" value="junit${version}" />
Expand Down
74 changes: 31 additions & 43 deletions doc/ReleaseNotes4.9.txt
@@ -1,54 +1,42 @@
## Summary of Changes in version 4.9 ##

### SuiteBuilder ###

A new way of declaring suites to run. SuiteBuilder allows for flexible
specification of where to find the classes containing tests, and how
to filter the resulting runners. This suite class lists the
explicit test classes to consider running, and then filters it down
to only those tests or classes annotated with `@Category(Yes.class)`:

@RunWith(SuiteBuilder.class)
public class OnlyYes {
@Classes
public Listed classes= new Listed(Yes1.class, Yes2.class, No1.class);

@RunnerFilter
public CategoryFilter filter= CategoryFilter.include(Yes.class);
}

We hope to soon include other implementations for the @Classes annotation,
including a classpath-searching test gatherer.

### ClassRule ###

The ClassRule annotation extends the idea of method-level Rules,
adding static fields that can affect the operation of a whole class:
The `ClassRule` annotation extends the idea of method-level Rules,
adding static fields that can affect the operation of a whole class.

public class Counter extends ExternalResource {
public int count = 0;
For example, here is a test suite that connects to a server once before
all the test classes run, and disconnects after they are finished:

@Override
protected void before() throws Throwable {
count++;
}
}
@RunWith(Suite.class)
@SuiteClasses({A.class, B.class, C.class})
public class UsesExternalResource {
public static Server myServer= new Server();

@Rule
public static ExternalResource resource= new ExternalResource() {
@Override
protected void before() throws Throwable {
myServer.connect();
};

public class ExampleTestWithClassRule {
@ClassRule
public static Counter counter= new Counter();

@Test
public void firstTest() {
assertEquals(1, counter.count);
}

@Test
public void secondTest() {
assertEquals(1, counter.count);
}
@Override
protected void after() {
myServer.disconnect();
};
};

@Test public void test1() { ... }
@Test public void test2() { ... }
@Test public void test3() { ... }
}

### TestRule ###

In JUnit 4.9, fields that can be annotated with either `@Rule` or `@ClassRule`
should be of type `TestRule`. The old `MethodRule` type, which only made sense
for method-level rules, is now deprecated.

### Bug fixes ###

- github#98: assumeTrue() does not work with expected exceptions
- github#98: assumeTrue() does not work with expected exceptions
6 changes: 5 additions & 1 deletion src/main/java/org/junit/ClassRule.java
Expand Up @@ -31,7 +31,7 @@
*
* &#064;RunWith(Suite.class)
* &#064;SuiteClasses({A.class, B.class, C.class})
* public static class UsesExternalResource {
* public class UsesExternalResource {
* public static Server myServer= new Server();
*
* &#064;Rule
Expand All @@ -46,6 +46,10 @@
* myServer.disconnect();
* };
* };
*
* &#064;Test public void test1() { ... }
* &#064;Test public void test2() { ... }
* &#064;Test public void test3() { ... }
* }
* </pre>
*
Expand Down

0 comments on commit b310cd5

Please sign in to comment.