Skip to content

Commit 8d98dc2

Browse files
committed
Update release notes with details on pull 986
1 parent d1e6bd8 commit 8d98dc2

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Diff for: doc/ReleaseNotes4.12.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,23 @@ If a custom failure message is not provided, a default message is used.
136136
When a test times out, a `org.junit.runners.model.TestTimedOutException` is now thrown instead of a plain `java.lang.Exception`.
137137

138138

139-
### [Pull request #742:](https://github.com/junit-team/junit/pull/742) `Timeout` exceptions now include stack trace from stuck thread (experimental)
139+
### [Pull request #742:](https://github.com/junit-team/junit/pull/742) [Pull request #986:](https://github.com/junit-team/junit/pull/986) `Timeout` exceptions now include stack trace from stuck thread (experimental)
140140

141-
`Timeout` exceptions try to determine if there is a child thread causing the problem, and if so its stack trace is included in the exception in addition to the one of the main thread. This feature must be enabled with a rule such as `new Timeout(100, TimeUnit.MILLISECONDS).lookingForStuckThread(true)`.
141+
`Timeout` exceptions try to determine if there is a child thread causing the problem, and if so its stack trace is included in the exception in addition to the one of the main thread. This feature must be enabled with the timeout rule by creating it through the new `Timeout.builder()` method:
142+
143+
```java
144+
public class HasGlobalTimeout {
145+
@Rule public final TestRule timeout = Timeout.builder()
146+
.withTimeout(10, TimeUnit.SECONDS)
147+
.withLookingForStuckThread(true)
148+
.build()
149+
@Test
150+
public void testInfiniteLoop() {
151+
for (;;) {
152+
}
153+
}
154+
}
155+
```
142156

143157

144158
### [Pull request #544:](https://github.com/junit-team/junit/pull/544) New constructor and factories in `Timeout`
@@ -147,17 +161,21 @@ When a test times out, a `org.junit.runners.model.TestTimedOutException` is now
147161
A new constructor is available: `Timeout(long timeout, TimeUnit unit)`. It enables you to use different granularities of time units like `NANOSECONDS`, `MICROSECONDS`, `MILLISECONDS`, and `SECONDS`. Examples:
148162

149163
```java
150-
@Rule public final TestRule globalTimeout = new Timeout(50, TimeUnit.MILLISECONDS);
164+
@Rule public final TestRule globalTimeout = new Timeout(50, TimeUnit.MILLISECONDS);
165+
```
151166

152-
@Rule public final TestRule globalTimeout = new Timeout(10, TimeUnit.SECONDS);
167+
```java
168+
@Rule public final TestRule globalTimeout = new Timeout(10, TimeUnit.SECONDS);
153169
```
154170

155171
and factory methods in `Timeout`:
156172

157173
```java
158-
@Rule public final TestRule globalTimeout = Timeout.millis(50);
174+
@Rule public final TestRule globalTimeout = Timeout.millis(50);
175+
```
159176

160-
@Rule public final TestRule globalTimeout = Timeout.seconds(10);`
177+
```java
178+
@Rule public final TestRule globalTimeout = Timeout.seconds(10);`
161179
```
162180

163181
This usage avoids the truncation, which was the problem in the deprecated constructor `Timeout(int millis)` when casting `long` to `int`.

0 commit comments

Comments
 (0)