From ce862aa91f5fad9511fdb9bc778388df8073d62a Mon Sep 17 00:00:00 2001 From: Mohammad Saddam Hossain Date: Sun, 18 Oct 2026 07:18:59 +0530 Subject: [PATCH] chore(cucumber): tidy #158 follow-ups Remove unused variable/imports from the new tests and document the isTestNgExecution heuristic. Co-Authored-By: Claude Sonnet 5.5 --- src/main/java/com/seleniumboot/cucumber/CucumberHooks.java | 1 + src/test/java/com/seleniumboot/unit/CucumberQuarantineTest.java | 2 -- .../com/seleniumboot/unit/SeleniumBootLauncherListenerTest.java | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/seleniumboot/cucumber/CucumberHooks.java b/src/main/java/com/seleniumboot/cucumber/CucumberHooks.java index 9631900..bd4f00a 100644 --- a/src/main/java/com/seleniumboot/cucumber/CucumberHooks.java +++ b/src/main/java/com/seleniumboot/cucumber/CucumberHooks.java @@ -258,6 +258,7 @@ private static void abortQuarantinedScenario(String reason) { } } + /** Heuristic: a TestNG result is current only on a TestNG thread. Cucumber launched from inside a TestNG test is treated as TestNG. */ private static boolean isTestNgExecution() { try { return org.testng.Reporter.getCurrentTestResult() != null; diff --git a/src/test/java/com/seleniumboot/unit/CucumberQuarantineTest.java b/src/test/java/com/seleniumboot/unit/CucumberQuarantineTest.java index 77ee066..5ebb174 100644 --- a/src/test/java/com/seleniumboot/unit/CucumberQuarantineTest.java +++ b/src/test/java/com/seleniumboot/unit/CucumberQuarantineTest.java @@ -1,7 +1,6 @@ package com.seleniumboot.unit; import com.seleniumboot.cucumber.CucumberHooks; -import com.seleniumboot.internal.SeleniumBootContext; import com.seleniumboot.quarantine.QuarantineLoader; import io.cucumber.java.Before; import io.cucumber.java.Scenario; @@ -159,7 +158,6 @@ public void checkQuarantine_notQuarantined_doesNotThrow() throws Exception { public static class QuarantineStepDefinitions { @Before("@quarantine") public void beforeScenario(Scenario scenario) { - CucumberHooks hooks = new CucumberHooks(); // In a real run, Cucumber invokes hooks; here we directly invoke quarantine check try { Method m = CucumberHooks.class.getDeclaredMethod("checkCucumberQuarantine", Scenario.class); diff --git a/src/test/java/com/seleniumboot/unit/SeleniumBootLauncherListenerTest.java b/src/test/java/com/seleniumboot/unit/SeleniumBootLauncherListenerTest.java index 2a50265..1514991 100644 --- a/src/test/java/com/seleniumboot/unit/SeleniumBootLauncherListenerTest.java +++ b/src/test/java/com/seleniumboot/unit/SeleniumBootLauncherListenerTest.java @@ -3,7 +3,6 @@ import com.seleniumboot.hooks.ExecutionHook; import com.seleniumboot.hooks.HookRegistry; import com.seleniumboot.junit5.SeleniumBootLauncherListener; -import com.seleniumboot.precondition.BaseConditions; import com.seleniumboot.precondition.PreConditionRegistry; import com.seleniumboot.testmanagement.TestManagementReporter; import org.testng.annotations.AfterMethod;