дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-27 21:12:34 +02:00
With Run tests using: OpenIDEA, every line a JUnit Platform test printed showed twice: the runner enabled JUnit's output capture, whose StreamInterceptor also writes each line to the original System.out, and then reported the captured text again as testStdOut. The runner now captures System.out / System.err per thread itself, as Junit4Runner does: a thread's lines while it runs a test or a class's set-up go only into that test's or class's testStdOut / testStdErr, other output passes through, and JUnit's capture is turned off explicitly. The console now shows testStdErr as stderr, and "Show console when a message is printed to stderr" fires for it (also for Junit4Runner and the Gradle test init script). Fixes #6332 Co-authored-by: wildcatDownstairs <[email protected]>
31 рядки
1.7 KiB
Markdown
31 рядки
1.7 KiB
Markdown
# JUnit runner
|
||
|
||
`ai.openidea.junit.Runner` runs the JUnit tests named by its arguments
|
||
(`com.acme.OrderTest`, `com.acme.OrderTest#method`; a method selects every overload, so
|
||
parameterized tests run too) and prints each test as the TeamCity service messages of
|
||
`src/features/run/gradleTests.gradle`, which the Run window's JVM parser already reads. It exits
|
||
with 1 when a test failed or none ran.
|
||
|
||
A test's stdout and stderr are reported with it (`testStdOut`, `testStdErr`), line by line as they
|
||
are written; a class's own output (static initializers, `@BeforeAll`) with the class, and output
|
||
outside any test, such as a thread the test started, is printed as is. Each line is printed once:
|
||
JUnit's own output capture, which also copies everything to the original stream, stays off.
|
||
|
||
JUnit Platform tests run on the Platform launcher. JUnit 4 and JUnit 3 tests run on JUnit 4's own
|
||
`JUnitCore` (`Junit4Runner`) when the classpath has no JUnit Platform, or one without the Vintage
|
||
engine, so a JUnit 4 project needs nothing beyond its `junit` dependency.
|
||
|
||
OpenIDEA starts it for the gutter's JUnit tests of Maven modules (Settings › Maven › Run tests
|
||
using: OpenIDEA) as `java -ea -cp <test classpath>:<runner>[:<launcher>] ai.openidea.junit.Runner …`.
|
||
`ide_sdk::java::junit_launcher` picks `junit-platform-launcher` of the engine's version (none for
|
||
JUnit 4 alone), and `ide_build::surefire` reads the module's Surefire configuration for the JVM
|
||
(IDEA's `MavenJUnitPatcher`).
|
||
|
||
The jar is committed and embedded by `ide-sdk` (`junit_runner_jar`). Rebuild it after changing
|
||
the source, and check it against JUnit 5 and JUnit 4 with:
|
||
|
||
```sh
|
||
python3 build.py --test
|
||
python3 build.py
|
||
```
|