Skip to content

Commit db82674

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

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

Diff for: doc/ReleaseNotes4.12.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,24 @@ 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+
150+
@Test
151+
public void testInfiniteLoop() {
152+
for (;;) {
153+
}
154+
}
155+
}
156+
```
142157

143158

144159
### [Pull request #544:](https://github.com/junit-team/junit/pull/544) New constructor and factories in `Timeout`
@@ -147,17 +162,21 @@ When a test times out, a `org.junit.runners.model.TestTimedOutException` is now
147162
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:
148163

149164
```java
150-
@Rule public final TestRule globalTimeout = new Timeout(50, TimeUnit.MILLISECONDS);
165+
@Rule public final TestRule globalTimeout = new Timeout(50, TimeUnit.MILLISECONDS);
166+
```
151167

152-
@Rule public final TestRule globalTimeout = new Timeout(10, TimeUnit.SECONDS);
168+
```java
169+
@Rule public final TestRule globalTimeout = new Timeout(10, TimeUnit.SECONDS);
153170
```
154171

155172
and factory methods in `Timeout`:
156173

157174
```java
158-
@Rule public final TestRule globalTimeout = Timeout.millis(50);
175+
@Rule public final TestRule globalTimeout = Timeout.millis(50);
176+
```
159177

160-
@Rule public final TestRule globalTimeout = Timeout.seconds(10);`
178+
```java
179+
@Rule public final TestRule globalTimeout = Timeout.seconds(10);`
161180
```
162181

163182
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)