You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/ReleaseNotes4.12.md
+104-3
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,28 @@ Version 4.11 added `Assert.assertEquals()` for `float` parameters with a delta,
17
17
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`.
18
18
19
19
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:
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
+
20
33
# Test Runners
21
34
22
35
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
24
42
25
43
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.
26
44
@@ -137,10 +155,17 @@ thrown.reportMissingExceptionWithMessage("FAIL: Expected exception to be thrown"
137
155
If a custom failure message is not provided, a default message is used.
138
156
139
157
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
+
140
165
# Timeout for Tests
141
166
*See also [Timeout for tests](https://github.com/junit-team/junit/wiki/Timeout-for-tests)*
142
167
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
144
169
145
170
When a test times out, a `org.junit.runners.model.TestTimedOutException` is now thrown instead of a plain `java.lang.Exception`.
146
171
@@ -225,6 +250,8 @@ public class HasGlobalTimeout {
225
250
```
226
251
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`.
227
252
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
+
228
255
229
256
# Parameterized Tests
230
257
@@ -242,7 +269,7 @@ The factory for creating the `Runner` instance of a single set of parameters is
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:
248
275
@@ -342,6 +369,31 @@ If you call `TemporaryFolder.newFolder("foo/bar")` in JUnit 4.10 the method retu
342
369
343
370
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.
344
371
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.
345
397
346
398
# Theories
347
399
@@ -629,3 +681,52 @@ While using JUnit in Android apps, if any other referenced library has a file na
629
681
`Error generating final archive: Found duplicate file for APK: LICENSE.txt`
630
682
631
683
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.
0 commit comments