Skip to content

Commit e1f57db

Browse files
kcooneykcooney
kcooney
authored andcommitted
Merge branch 'master' into trim-stack-trace
2 parents 7451fe0 + 9c337dc commit e1f57db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+868
-333
lines changed

.classpath

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<classpath>
33
<classpathentry kind="src" path="src/main/java"/>
44
<classpathentry kind="src" path="src/test/java"/>
5+
<classpathentry kind="src" path="src/test/resources"/>
6+
<classpathentry kind="src" path="src/main/resources"/>
57
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
68
<classpathentry exported="true" kind="lib" path="lib/hamcrest-core-1.3.jar" sourcepath="lib/hamcrest-core-1.3-sources.jar"/>
79
<classpathentry kind="output" path="bin"/>

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: java
2-
script: mvn verify javadoc:javadoc
2+
script: mvn verify javadoc:javadoc site:site
33
jdk:
44
- oraclejdk7
55
- oraclejdk8

doc/ReleaseNotes4.12.md

+104-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,28 @@ Version 4.11 added `Assert.assertEquals()` for `float` parameters with a delta,
1717
In the usual case, where the array elements are in fact exactly equal, the potentially expensive reflection-based loop to compare them is avoided by using `Arrays.deepEquals()` first. The exact comparison is only executed when `deepEquals()` returns `false`.
1818

1919

20+
# Command-line options
21+
### [Pull request #647:](https://github.com/junit-team/junit/pull/647) Support command-line `--filter` param.
22+
23+
When running JUnit from the command line, a command-line parameter can be supplied using `--filter`, which supplies a filter that will restrict which tests and subtests from the rest of the command will be run. For example, this will run only the tests in ExampleTestSuite that are in categories Cat1 or Cat2:
24+
25+
```
26+
java org.junit.runner.JUnitCore \
27+
--filter=org.junit.experimental.categories.IncludeCategories=pkg.of.Cat1,pkg.of.Cat2 \
28+
com.example.ExampleTestSuite
29+
```
30+
31+
In general, the argument to `--filter` should be `ClassName=param`, where `ClassName` names an implementation of `FilterFactory`, whose `createFilter` method will be called with an instance of `FilterFactoryParams` that contains `"param"`, in order to return the filter to be applied.
32+
2033
# Test Runners
2134

2235

23-
### [Pull request #817:] (https://github.com/junit-team/junit/pull/817) Support for context hierarchies
36+
### [Pull request #763:](https://github.com/junit-team/junit/pull/763) Allow custom test runners to create their own TestClasses and customize the scanning of annotations.
37+
38+
This introduces some extension points to `ParentRunner` to allow subclasses to control creation
39+
of the `TestClass` instance and to scan for annotations.
40+
41+
### [Pull request #817:](https://github.com/junit-team/junit/pull/817) Support for context hierarchies
2442

2543
The `AnnotatedBuilder` is a strategy for constructing runners for test classes that have been annotated with the `@RunWith` annotation. All tests within such a class will be executed using the runner that was specified within the annotation.
2644

@@ -137,10 +155,17 @@ thrown.reportMissingExceptionWithMessage("FAIL: Expected exception to be thrown"
137155
If a custom failure message is not provided, a default message is used.
138156

139157

158+
### [Pull request #1013:](https://github.com/junit-team/junit/pull/1013) Make ErrorCollector#checkSucceeds generic
159+
160+
The method `ErrorCollector.checkSucceeds()` is now generic. Previously, you could only pass
161+
in a `Callable<Object>` and it returned `Object`. You can now pass any `Callable` and the
162+
return type will match the type of the callable.
163+
164+
140165
# Timeout for Tests
141166
*See also [Timeout for tests](https://github.com/junit-team/junit/wiki/Timeout-for-tests)*
142167

143-
### [Pull request #823:] (https://github.com/junit-team/junit/pull/823) Throw `TestFailedOnTimeoutException` instead of plain `Exception` on timeout
168+
### [Pull request #823:](https://github.com/junit-team/junit/pull/823) Throw `TestFailedOnTimeoutException` instead of plain `Exception` on timeout
144169

145170
When a test times out, a `org.junit.runners.model.TestTimedOutException` is now thrown instead of a plain `java.lang.Exception`.
146171

@@ -225,6 +250,8 @@ public class HasGlobalTimeout {
225250
```
226251
Each test is run in a new _daemon_ thread. If the specified timeout elapses before the test completes, its execution is interrupted via `Thread#interrupt()`. This happens in interruptable I/O (operations throwing `java.io.InterruptedIOException` and `java.nio.channels.ClosedByInterruptException`), locks (package `java.util.concurrent`) and methods in `java.lang.Object` and `java.lang.Thread` throwing `java.lang.InterruptedException`.
227252

253+
### [Pull request #876:](https://github.com/junit-team/junit/pull/876) The timeout rule never times out if you pass in a timeout of zero.
254+
228255

229256
# Parameterized Tests
230257

@@ -242,7 +269,7 @@ The factory for creating the `Runner` instance of a single set of parameters is
242269
# Rules
243270

244271

245-
### [Pull request #552:](https://github.com/junit-team/junit/pull/552) `Stopwatch` rule
272+
### [Pull request #552:](https://github.com/junit-team/junit/pull/552) [Pull request #937:](https://github.com/junit-team/junit/pull/937) `Stopwatch` rule
246273

247274
The `Stopwatch` Rule notifies one of its own protected methods of the time spent by a test. Override them to get the time in nanoseconds. For example, this class will keep logging the time spent by each passed, failed, skipped, and finished test:
248275

@@ -342,6 +369,31 @@ If you call `TemporaryFolder.newFolder("foo/bar")` in JUnit 4.10 the method retu
342369

343370
With this fix, folder names are validated to contain single path name. If the folder name consists of multiple path names, an exception is thrown stating that usage of multiple path components in a string containing folder name is disallowed.
344371

372+
### [Pull request #1015:](https://github.com/junit-team/junit/pull/1015) Methods annotated with `Rule` can return a `MethodRule`.
373+
374+
Methods annotated with `@Rule` can now return either a `TestRule` (or subclass) or a
375+
`MethodRule` (or subclass).
376+
377+
Prior to this change, all public methods annotated with `@Rule` were called, but the
378+
return value was ignored if it could not be assigned to a `TestRule`. After this change,
379+
the method is only called if the return type could be assigned to `TestRule` or
380+
`MethodRule`. For methods annotated with `@Rule` that return other values, see the notes
381+
for pull request #1020.
382+
383+
### [Pull request #1020:](https://github.com/junit-team/junit/pull/1020) Added validation that @ClassRule should only be implementation of TestRule.
384+
385+
Prior to this change, fields annotated with `@ClassRule` that did not have a type of `TestRule`
386+
(or a class that implements `TestRule`) were ignored. With this change, the test will fail
387+
with a validation error.
388+
389+
Prior to this change, methods annotated with `@ClassRule` that did specify a return type
390+
of `TestRule`(or a class that implements `TestRule`) were ignored. With this change, the test
391+
will fail with a validation error.
392+
393+
### [Pull request #1021:](https://github.com/junit-team/junit/pull/1021) JavaDoc of TemporaryFolder: folder not guaranteed to be deleted.
394+
395+
Adjusted JavaDoc of TemporaryFolder to reflect that temporary folders are not guaranteed to be
396+
deleted.
345397

346398
# Theories
347399

@@ -629,3 +681,52 @@ While using JUnit in Android apps, if any other referenced library has a file na
629681
`Error generating final archive: Found duplicate file for APK: LICENSE.txt`
630682

631683
To avoid this, the license file has been renamed to `LICENSE-junit.txt`
684+
685+
686+
### [Pull request #962:](https://github.com/junit-team/junit/pull/962) Do not include thread start time in test timeout measurements.
687+
688+
The time it takes to start a thread can be surprisingly large.
689+
Especially in virtualized cloud environments where noisy neighbours.
690+
This change reduces the probability of non-deterministic failures of
691+
tests with timeouts (@Test(timeout=…)) by not beginning the timeout
692+
clock until we have observed the starting of the task thread – the
693+
thread that runs the actual test. This should make tests with small
694+
timeout values more reliable in general, and especially in cloud CI
695+
environments.
696+
697+
# Fixes to issues introduced in JUnit 4.12
698+
699+
The following section lists fixes to problems introduced in the first
700+
release candidates for JUnit 4.12. You can ignore this section if you are
701+
trying to understand the changes between 4.11 and 4.12.
702+
703+
### [Pull request #961:](https://github.com/junit-team/junit/pull/961) Restore field names with f prefix.
704+
705+
In order to make the JUnit code more consistent with current coding practices, we changed
706+
a number of field names to not start with the prefix "f". Unfortunately, at least one IDE
707+
referenced a private field via reflection. This change reverts the field names for fields
708+
known to be read via reflection.
709+
710+
### [Pull request #988:](https://github.com/junit-team/junit/pull/988) Revert "Delete classes that are deprecated for six years."
711+
712+
In [745ca05](https://github.com/junit-team/junit/commit/745ca05dccf5cc907e43a58142bb8be97da2b78f)
713+
we removed classes that were deprecated for many releases. There was some concern that people
714+
might not expect classes to be removed in a 4.x release. Even though we are not aware of any
715+
problems from the deletion, we decided to add them back.
716+
717+
These classes may be removed in JUnit 5.0 or later.
718+
719+
### [Pull request #989:](https://github.com/junit-team/junit/pull/989) Add JUnitSystem.exit() back.
720+
721+
In [917a88f](https://github.com/junit-team/junit/commit/917a88fad06ce108a596a8fdb4607b1a2fbb3f3e)
722+
the exit() method in JUnit was removed. This caused problems for at least one user. Even
723+
though this class is in an internal package, we decided to add it back, and deprecated it.
724+
725+
This method may be removed in JUnit 5.0 or later.
726+
727+
### [Pull request #994:](https://github.com/junit-team/junit/pull/994) [Pull request #1000:](https://github.com/junit-team/junit/pull/1000) Ensure serialization compatibility where possible.
728+
729+
JUnit 4.12 RC1 introduced serilization incompatibilities with some of the classes. For example,
730+
these pre-release versions of JUnit could not read instances of `Result` that were serialized
731+
in JUnit 4.11 and earlier. These changes fix that problem.
732+

pom.xml

+24-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>junit</groupId>
66
<artifactId>junit</artifactId>
7-
<version>4.12-SNAPSHOT</version>
7+
<version>4.13-SNAPSHOT</version>
88

99
<name>JUnit</name>
1010
<description>JUnit is a unit testing framework for Java, created by Erich Gamma and Kent Beck.</description>
@@ -211,7 +211,7 @@
211211
java compiler plugin forked in extra process
212212
-->
213213
<artifactId>maven-compiler-plugin</artifactId>
214-
<version>3.1</version>
214+
<version>3.2</version>
215215
<configuration>
216216
<encoding>${project.build.sourceEncoding}</encoding>
217217
<source>${jdkVersion}</source>
@@ -232,7 +232,7 @@
232232
<plugin>
233233
<groupId>org.codehaus.mojo</groupId>
234234
<artifactId>animal-sniffer-maven-plugin</artifactId>
235-
<version>1.11</version>
235+
<version>1.13</version>
236236
<executions>
237237
<execution>
238238
<id>signature-check</id>
@@ -256,7 +256,7 @@
256256
our junit suite "AllTests" after the sources are compiled.
257257
-->
258258
<artifactId>maven-surefire-plugin</artifactId>
259-
<version>2.17</version>
259+
<version>2.18.1</version>
260260
<configuration>
261261
<test>org/junit/tests/AllTests.java</test>
262262
<useSystemClassLoader>true</useSystemClassLoader>
@@ -269,7 +269,7 @@
269269
in to jar archive. See target/junit-*-sources.jar.
270270
-->
271271
<artifactId>maven-source-plugin</artifactId>
272-
<version>2.2.1</version>
272+
<version>2.4</version>
273273
</plugin>
274274
<plugin>
275275
<!--
@@ -278,7 +278,7 @@
278278
in jar archive target/junit-*-javadoc.jar.
279279
-->
280280
<artifactId>maven-javadoc-plugin</artifactId>
281-
<version>2.9.1</version>
281+
<version>2.10.1</version>
282282
<configuration>
283283
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
284284
<show>protected</show>
@@ -287,7 +287,7 @@
287287
<detectLinks>false</detectLinks>
288288
<linksource>true</linksource>
289289
<keywords>true</keywords>
290-
<use>false</use>
290+
<use>true</use>
291291
<windowtitle>JUnit API</windowtitle>
292292
<encoding>UTF-8</encoding>
293293
<locale>en</locale>
@@ -311,7 +311,7 @@
311311
</plugin>
312312
<plugin>
313313
<artifactId>maven-release-plugin</artifactId>
314-
<version>2.5</version>
314+
<version>2.5.1</version>
315315
<configuration>
316316
<mavenExecutorId>forked-path</mavenExecutorId>
317317
<useReleaseProfile>false</useReleaseProfile>
@@ -321,7 +321,7 @@
321321
</plugin>
322322
<plugin>
323323
<artifactId>maven-site-plugin</artifactId>
324-
<version>3.3</version>
324+
<version>3.4</version>
325325
<dependencies>
326326
<dependency>
327327
<groupId>com.github.stephenc.wagon</groupId>
@@ -337,7 +337,7 @@
337337
</plugin>
338338
<plugin>
339339
<artifactId>maven-jar-plugin</artifactId>
340-
<version>2.4</version>
340+
<version>2.5</version>
341341
<configuration>
342342
<archive>
343343
<addMavenDescriptor>false</addMavenDescriptor>
@@ -381,16 +381,17 @@
381381
</plugin>
382382
<plugin>
383383
<artifactId>maven-javadoc-plugin</artifactId>
384-
<version>2.9.1</version>
384+
<version>2.10.1</version>
385385
<configuration>
386+
<destDir>javadoc/latest</destDir>
386387
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
387388
<show>protected</show>
388389
<author>false</author>
389390
<version>false</version>
390391
<detectLinks>false</detectLinks>
391392
<linksource>true</linksource>
392393
<keywords>true</keywords>
393-
<use>false</use>
394+
<use>true</use>
394395
<windowtitle>JUnit API</windowtitle>
395396
<encoding>UTF-8</encoding>
396397
<locale>en</locale>
@@ -514,6 +515,16 @@
514515
</plugin>
515516
</plugins>
516517
</build>
518+
<reporting>
519+
<plugins>
520+
<plugin>
521+
<artifactId>maven-javadoc-plugin</artifactId>
522+
<configuration>
523+
<additionalparam>-Xdoclint:accessibility -Xdoclint:reference</additionalparam>
524+
</configuration>
525+
</plugin>
526+
</plugins>
527+
</reporting>
517528
</profile>
518529
<profile>
519530
<id>fast-tests</id>
@@ -529,7 +540,7 @@
529540
<dependency>
530541
<groupId>org.apache.maven.surefire</groupId>
531542
<artifactId>surefire-junit47</artifactId>
532-
<version>2.17</version>
543+
<version>2.18</version>
533544
</dependency>
534545
</dependencies>
535546
</plugin>

src/main/java/junit/extensions/TestDecorator.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* test decorators. Test decorator subclasses can be introduced to add behaviour
1010
* before or after a test is run.
1111
*/
12+
@SuppressWarnings("deprecation")
1213
public class TestDecorator extends Assert implements Test {
1314
protected Test fTest;
1415

src/main/java/junit/framework/ComparisonCompactor.java

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public ComparisonCompactor(int contextLength, String expected, String actual) {
1818
fActual = actual;
1919
}
2020

21+
@SuppressWarnings("deprecation")
2122
public String compact(String message) {
2223
if (fExpected == null || fActual == null || areStringsEqual()) {
2324
return Assert.format(message, fExpected, fActual);

0 commit comments

Comments
 (0)