
utilities.TestRunningManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AUTOTESTIMATIC-JAVA Show documentation
Show all versions of AUTOTESTIMATIC-JAVA Show documentation
An open-source Selenium Java-based Test automation Framework that allows you to perform multiple actions
to test a web application's functionality, behaviour, which provides easy to use syntax,
and easy to set up environment according to the needed requirements for testing
package utilities;
import org.junit.platform.launcher.LauncherSessionListener;
import org.testng.ITestNGListener;
import org.testng.TestNG;
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Stream;
public class TestRunningManager {
private static boolean isJunitRunBool = false;
private static boolean isTestNGRunBool = false;
private TestRunningManager() {
}
public static void initializeRunConfigurations() {
identifyRunType();
if (isTestNGRunBool) {
ServiceLoader serviceLoader = ServiceLoader.load(ITestNGListener.class);
serviceLoader.reload();
LoggingManager.info("Start Running Tests via TestNG Runner");
}
if (isJunitRunBool) {
ServiceLoader serviceLoader =
ServiceLoader.load(LauncherSessionListener.class);
serviceLoader.reload();
LoggingManager.info("Start Running Tests via JUnit 5 Runner");
}
}
private static void identifyRunType() {
Supplier> stacktraceSupplier = () -> Arrays.stream((new Throwable()).getStackTrace()).map(StackTraceElement::getClassName);
boolean isUsingJunitDiscovery = stacktraceSupplier.get().anyMatch(org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.class.getCanonicalName()::equals);
boolean isUsingTestNG = stacktraceSupplier.get().anyMatch(TestNG.class.getCanonicalName()::equals);
if (isUsingJunitDiscovery || isUsingTestNG) {
isTestNGRunBool = true;
} else {
isJunitRunBool = true;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy