diff --git a/build.gradle b/build.gradle index ff1043b..da87556 100644 --- a/build.gradle +++ b/build.gradle @@ -52,22 +52,6 @@ dependencies { -// -// -// // -------------------- ТЕСТЫ -------------------- -// testImplementation platform('org.junit:junit-bom:5.11.4') -// testImplementation 'org.junit.jupiter:junit-jupiter' -// testImplementation 'org.junit.platform:junit-platform-suite-api' -// testRuntimeOnly 'org.junit.platform:junit-platform-suite-engine' -// -// testRuntimeOnly "org.junit.platform:junit-platform-launcher" -// -// // Suite (чтобы запустить классы в заданном порядке) -// testImplementation "org.junit.platform:junit-platform-suite:1.10.2" -// -// // Нужно, чтобы TestExecutionListener (RussianSummaryListener) корректно подхватывался -// testRuntimeOnly 'org.junit.platform:junit-platform-launcher' -//} // -------------------- ТЕСТЫ (JUnit 5) -------------------- // Один BOM на всё семейство JUnit (Jupiter + Platform модули) diff --git a/src/test/java/test/it/IT_00_Suite.java b/src/test/java/test/it/IT_00_Suite.java index 9ccd233..4c3f3f3 100644 --- a/src/test/java/test/it/IT_00_Suite.java +++ b/src/test/java/test/it/IT_00_Suite.java @@ -9,9 +9,6 @@ import test.it.ws.*; * * Запуск: * ./gradlew test --tests test.it.IT_00_Suite - * - * Важно: - * - ItRunContext.initOnce() будет вызван слушателем RussianSummaryListener ДО тестов. */ @Suite @SelectClasses({ diff --git a/src/test/java/test/it/IT_RunAllMain.java b/src/test/java/test/it/IT_RunAllMain.java index 0df4dff..a0e8791 100644 --- a/src/test/java/test/it/IT_RunAllMain.java +++ b/src/test/java/test/it/IT_RunAllMain.java @@ -56,7 +56,7 @@ public class IT_RunAllMain { // 3) IT_03_AddBlock_NoAuth (оставлен как есть, поэтому запускаем через его main) // Если он упадёт — он кинет исключение. Мы перехватим и посчитаем как fail=1. TestLog.stepTitle("RUN: IT_03_AddBlock_NoAuth (main)"); - int f3 = 0; //TestLog.runOne("IT_03_AddBlock_NoAuth", () -> IT_03_AddBlock_NoAuth.main(new String[0])); + int f3 = IT_03_AddBlock_NoAuth.run(); failed += f3; passed += (f3 == 0 ? 1 : 0); // Итоговый короткий отчёт diff --git a/src/test/java/test/it/ws/IT_03_AddBlock_NoAuth.java b/src/test/java/test/it/ws/IT_03_AddBlock_NoAuth.java index 5b83d0d..a6d351d 100644 --- a/src/test/java/test/it/ws/IT_03_AddBlock_NoAuth.java +++ b/src/test/java/test/it/ws/IT_03_AddBlock_NoAuth.java @@ -35,10 +35,13 @@ import static org.junit.jupiter.api.Assertions.*; public class IT_03_AddBlock_NoAuth { public static void main(String[] args) { - ItRunContext.initIfNeeded(); - ensureUserExists(); - new IT_03_AddBlock_NoAuth().addBlock_shouldAppendHeaderThenTextThenReaction(); - TestLog.pass("IT_03_AddBlock_NoAuth: OK"); + int failed = run(); + System.exit(failed); + } + + /** Запуск одного теста (standalone). Возвращает 0 если ок, 1 если упал. */ + public static int run() { + return TestLog.runOne("IT_03_AddBlock_NoAuth", IT_03_AddBlock_NoAuth::testBody); } @BeforeAll @@ -57,10 +60,16 @@ public class IT_03_AddBlock_NoAuth { @Test void addBlock_shouldAppendHeaderThenTextThenReaction() { + // JUnit-режим: как обычно + testBody(); + } + + private static void testBody() { ItRunContext.initIfNeeded(); + ensureUserExists(); // таймаут на каждый one-shot запрос - Duration t = Duration.ofSeconds(8); + Duration t = Duration.ofSeconds(1); if (TestConfig.DEBUG()) { TestLog.titleBlock(""" diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties index 2fe8504..4c0d52d 100644 --- a/src/test/resources/junit-platform.properties +++ b/src/test/resources/junit-platform.properties @@ -1,5 +1 @@ -# ???????????? ??? ?????????, ????? ? ????? ??????? ??? "??????? ?????" ??-?????? -junit.platform.listeners.default=test.it.utils.RussianSummaryListener -# ?? ?????? ??????: ????????? ???????????? ?????????? ?? ?????? JUnit -junit.jupiter.execution.parallel.enabled=false