From e95ebf263d9decd8894b9f19f854b3a00f680a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gro=C3=9Fmann?= Date: Fri, 30 Aug 2024 16:12:32 +0200 Subject: [PATCH] Fixed dry run option --- .../report/hooks/ConfigMethodHook.java | 2 + .../report/hooks/TestMethodHook.java | 2 + .../pretest_testng/TestNGFeatureTest.java | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 integration-tests/src/test/java/io/testerra/test/pretest_testng/TestNGFeatureTest.java diff --git a/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/ConfigMethodHook.java b/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/ConfigMethodHook.java index fb3d0fe9a..0d7612890 100644 --- a/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/ConfigMethodHook.java +++ b/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/ConfigMethodHook.java @@ -43,11 +43,13 @@ public static void runHook(IConfigureCallBack callBack, ITestResult testResult) if (Report.Properties.LIST_TESTS.asBool()) { LOGGER.info("Dry run for list tests: " + testNGMethod.getMethodName()); + testResult.setStatus(ITestResult.SUCCESS); // no sleep return; } if (Testerra.Properties.DRY_RUN.asBool()) { if (dryRun(testNGMethod)) { + testResult.setStatus(ITestResult.SUCCESS); return; } } diff --git a/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/TestMethodHook.java b/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/TestMethodHook.java index 6fecc7d2b..8db07a050 100644 --- a/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/TestMethodHook.java +++ b/core/src/main/java/eu/tsystems/mms/tic/testframework/report/hooks/TestMethodHook.java @@ -49,10 +49,12 @@ public static void runHook(IHookCallBack callBack, ITestResult testResult) { if (Report.Properties.LIST_TESTS.asBool()) { LOGGER.info("Dry run for list tests: " + testNGMethod.getMethodName()); + testResult.setStatus(ITestResult.SUCCESS); // no sleep return; } else if (Testerra.Properties.DRY_RUN.asBool()) { if (dryRun(testNGMethod)) { + testResult.setStatus(ITestResult.SUCCESS); return; } } diff --git a/integration-tests/src/test/java/io/testerra/test/pretest_testng/TestNGFeatureTest.java b/integration-tests/src/test/java/io/testerra/test/pretest_testng/TestNGFeatureTest.java new file mode 100644 index 000000000..b53a458f7 --- /dev/null +++ b/integration-tests/src/test/java/io/testerra/test/pretest_testng/TestNGFeatureTest.java @@ -0,0 +1,46 @@ +package io.testerra.test.pretest_testng; + +import eu.tsystems.mms.tic.testframework.testing.TesterraTest; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created on 2024-08-30 + * + * @author mgn + */ +public class TestNGFeatureTest extends TesterraTest { + + @BeforeMethod + public void before_method() { + + } + + @BeforeMethod + public void beofre_method_failed() { + Assert.fail(); + } + + @Test + public void T01_testng_passed_test() { + + } + + @Test(dependsOnMethods = "T01_testng_passed_test") + public void T02_testng_depends_method() { + + } + + @Test + public void T03_testng_failed_test() { + Assert.fail(); + } + + @AfterMethod + public void after_method() { + + } + +}