29 12 25
В общем тесты работают. Только запускать их надо из специального класса :)
This commit is contained in:
parent
ae3838ccf2
commit
7fdc890a85
16
build.gradle
16
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) --------------------
|
// -------------------- ТЕСТЫ (JUnit 5) --------------------
|
||||||
// Один BOM на всё семейство JUnit (Jupiter + Platform модули)
|
// Один BOM на всё семейство JUnit (Jupiter + Platform модули)
|
||||||
|
|||||||
@ -9,9 +9,6 @@ import test.it.ws.*;
|
|||||||
*
|
*
|
||||||
* Запуск:
|
* Запуск:
|
||||||
* ./gradlew test --tests test.it.IT_00_Suite
|
* ./gradlew test --tests test.it.IT_00_Suite
|
||||||
*
|
|
||||||
* Важно:
|
|
||||||
* - ItRunContext.initOnce() будет вызван слушателем RussianSummaryListener ДО тестов.
|
|
||||||
*/
|
*/
|
||||||
@Suite
|
@Suite
|
||||||
@SelectClasses({
|
@SelectClasses({
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class IT_RunAllMain {
|
|||||||
// 3) IT_03_AddBlock_NoAuth (оставлен как есть, поэтому запускаем через его main)
|
// 3) IT_03_AddBlock_NoAuth (оставлен как есть, поэтому запускаем через его main)
|
||||||
// Если он упадёт — он кинет исключение. Мы перехватим и посчитаем как fail=1.
|
// Если он упадёт — он кинет исключение. Мы перехватим и посчитаем как fail=1.
|
||||||
TestLog.stepTitle("RUN: IT_03_AddBlock_NoAuth (main)");
|
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);
|
failed += f3; passed += (f3 == 0 ? 1 : 0);
|
||||||
|
|
||||||
// Итоговый короткий отчёт
|
// Итоговый короткий отчёт
|
||||||
|
|||||||
@ -35,10 +35,13 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
public class IT_03_AddBlock_NoAuth {
|
public class IT_03_AddBlock_NoAuth {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ItRunContext.initIfNeeded();
|
int failed = run();
|
||||||
ensureUserExists();
|
System.exit(failed);
|
||||||
new IT_03_AddBlock_NoAuth().addBlock_shouldAppendHeaderThenTextThenReaction();
|
}
|
||||||
TestLog.pass("IT_03_AddBlock_NoAuth: OK");
|
|
||||||
|
/** Запуск одного теста (standalone). Возвращает 0 если ок, 1 если упал. */
|
||||||
|
public static int run() {
|
||||||
|
return TestLog.runOne("IT_03_AddBlock_NoAuth", IT_03_AddBlock_NoAuth::testBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
@ -57,10 +60,16 @@ public class IT_03_AddBlock_NoAuth {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void addBlock_shouldAppendHeaderThenTextThenReaction() {
|
void addBlock_shouldAppendHeaderThenTextThenReaction() {
|
||||||
|
// JUnit-режим: как обычно
|
||||||
|
testBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testBody() {
|
||||||
ItRunContext.initIfNeeded();
|
ItRunContext.initIfNeeded();
|
||||||
|
ensureUserExists();
|
||||||
|
|
||||||
// таймаут на каждый one-shot запрос
|
// таймаут на каждый one-shot запрос
|
||||||
Duration t = Duration.ofSeconds(8);
|
Duration t = Duration.ofSeconds(1);
|
||||||
|
|
||||||
if (TestConfig.DEBUG()) {
|
if (TestConfig.DEBUG()) {
|
||||||
TestLog.titleBlock("""
|
TestLog.titleBlock("""
|
||||||
|
|||||||
@ -1,5 +1 @@
|
|||||||
# ???????????? ??? ?????????, ????? ? ????? ??????? ??? "??????? ?????" ??-??????
|
|
||||||
junit.platform.listeners.default=test.it.utils.RussianSummaryListener
|
|
||||||
|
|
||||||
# ?? ?????? ??????: ????????? ???????????? ?????????? ?? ?????? JUnit
|
|
||||||
junit.jupiter.execution.parallel.enabled=false
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user