дзеркало
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]>
58 рядки
1.2 KiB
Java
58 рядки
1.2 KiB
Java
package sample;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Disabled;
|
|
import org.junit.jupiter.api.Nested;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
import org.junit.jupiter.params.provider.ValueSource;
|
|
|
|
class SampleTest {
|
|
static {
|
|
System.out.println("loaded");
|
|
}
|
|
|
|
@BeforeAll
|
|
static void setUp() {
|
|
System.out.println("class set-up");
|
|
}
|
|
|
|
@Test
|
|
void passes() throws InterruptedException {
|
|
System.out.println("hello [ünï]");
|
|
System.err.println("to stderr");
|
|
Thread other = new Thread(() -> System.out.println("from a thread"));
|
|
other.start();
|
|
other.join();
|
|
}
|
|
|
|
@Test
|
|
void fails() {
|
|
assertEquals(1, 2, "it's wrong");
|
|
}
|
|
|
|
@Test
|
|
@Disabled
|
|
void disabled() {}
|
|
|
|
@Test
|
|
void aborted() {
|
|
assumeTrue(false);
|
|
}
|
|
|
|
@ParameterizedTest
|
|
@ValueSource(ints = {1, 2})
|
|
void parameterized(int n) {
|
|
assertEquals(1, n);
|
|
}
|
|
|
|
@Nested
|
|
class Inner {
|
|
@Test
|
|
void nested() {}
|
|
}
|
|
}
|