diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index ae04a012d2..0a08bc1a99 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java @@ -24,6 +24,7 @@ import io.mosip.testrig.apirig.dataprovider.BiometricDataProvider; import io.mosip.testrig.apirig.dbaccess.DBManager; +import io.mosip.testrig.apirig.report.EmailableReport; import io.mosip.testrig.apirig.utils.AdminTestUtil; import io.mosip.testrig.apirig.utils.AuthTestsUtil; import io.mosip.testrig.apirig.utils.CertificateGenerationUtil; @@ -51,6 +52,7 @@ public class MosipTestRunner { public static String jarUrl = MosipTestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath(); public static List languageList = new ArrayList<>(); + public static boolean skipAll = false; /** * C Main method to start mosip test execution @@ -137,7 +139,6 @@ public static void suiteSetup(String runType) { if (!runType.equalsIgnoreCase("JAR")) { AuthTestsUtil.removeOldMosipTempTestResource(); } - BaseTestCase.setReportName("auth"); BaseTestCase.currentModule = "auth"; BaseTestCase.certsForModule = "IDA"; DBManager.executeDBQueries(ConfigManager.getKMDbUrl(), ConfigManager.getKMDbUser(), ConfigManager.getKMDbPass(), @@ -174,8 +175,6 @@ private static void setLogLevels() { */ public static void startTestRunner() { File homeDir = null; - TestNG runner = new TestNG(); - List suitefiles = new ArrayList<>(); String os = System.getProperty("os.name"); LOGGER.info(os); if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) { @@ -187,14 +186,29 @@ public static void startTestRunner() { LOGGER.info("ELSE :" + homeDir); } for (File file : homeDir.listFiles()) { + TestNG runner = new TestNG(); + List suitefiles = new ArrayList<>(); + + BaseTestCase.setReportName("auth"); if (file.getName().toLowerCase().contains("auth")) { + if (file.getName().toLowerCase().contains("prerequisite")) { + BaseTestCase.setReportName("auth-prerequisite"); + } else { + // if the prerequisite total skipped/failed count is greater than zero + if (EmailableReport.getFailedCount() > 0 || EmailableReport.getSkippedCount() > 0) { +// skipAll = true; + } + + BaseTestCase.setReportName("auth"); + } suitefiles.add(file.getAbsolutePath()); + runner.setTestSuites(suitefiles); + System.getProperties().setProperty("testng.outpur.dir", "testng-report"); + runner.setOutputDirectory("testng-report"); + runner.run(); } } - runner.setTestSuites(suitefiles); - System.getProperties().setProperty("testng.outpur.dir", "testng-report"); - runner.setOutputDirectory("testng-report"); - runner.run(); + } public static String getGlobalResourcePath() { diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/utils/IdAuthenticationUtil.java b/api-test/src/main/java/io/mosip/testrig/apirig/utils/IdAuthenticationUtil.java index 4fc439810b..3773c049ae 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/utils/IdAuthenticationUtil.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/utils/IdAuthenticationUtil.java @@ -4,6 +4,7 @@ import org.testng.SkipException; import io.mosip.testrig.apirig.dto.TestCaseDTO; +import io.mosip.testrig.apirig.testrunner.MosipTestRunner; public class IdAuthenticationUtil extends AdminTestUtil { @@ -11,7 +12,11 @@ public class IdAuthenticationUtil extends AdminTestUtil { public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) { String testCaseName = testCaseDTO.getTestCaseName(); - + + if (MosipTestRunner.skipAll == true) { + throw new SkipException(GlobalConstants.PRE_REQUISITE_FAILED_MESSAGE); + } + if (SkipTestCaseHandler.isTestCaseInSkippedList(testCaseName)) { throw new SkipException(GlobalConstants.KNOWN_ISSUES); } diff --git a/api-test/testNgXmlFiles/authenticationPrerequisiteSuite.xml b/api-test/testNgXmlFiles/authenticationPrerequisiteSuite.xml new file mode 100644 index 0000000000..a9dbf77cea --- /dev/null +++ b/api-test/testNgXmlFiles/authenticationPrerequisiteSuite.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api-test/testNgXmlFiles/authenticationApi.xml b/api-test/testNgXmlFiles/authenticationSuite.xml similarity index 61% rename from api-test/testNgXmlFiles/authenticationApi.xml rename to api-test/testNgXmlFiles/authenticationSuite.xml index d7a844b9ee..29f23f9a1f 100644 --- a/api-test/testNgXmlFiles/authenticationApi.xml +++ b/api-test/testNgXmlFiles/authenticationSuite.xml @@ -8,121 +8,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -