forked from junit-team/junit4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update JUnit version, improve ClassRule javadoc, update release notes
- Loading branch information
Showing
3 changed files
with
37 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters