diff --git a/apitest/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/apitest/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index 2ece5cc0..af87775c 100644 --- a/apitest/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/apitest/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.CertsUtil; @@ -49,6 +50,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 @@ -72,6 +74,7 @@ public static void main(String[] arg) { } else { ExtractResource.copyCommonResources(); } + AdminTestUtil.init(); InjiCertifyConfigManager.init(); suiteSetup(getRunType()); SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt"); @@ -135,7 +138,6 @@ public static void suiteSetup(String runType) { InjiCertifyConfigManager.getMasterDbUser(), InjiCertifyConfigManager.getMasterDbPass(), InjiCertifyConfigManager.getMasterDbSchema(), getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt"); - BaseTestCase.setReportName(GlobalConstants.INJICERTIFY); AdminTestUtil.copymoduleSpecificAndConfigFile(GlobalConstants.INJICERTIFY); BaseTestCase.otpListener = new OTPListener(); BaseTestCase.otpListener.run(); @@ -158,8 +160,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")) { @@ -171,14 +171,26 @@ public static void startTestRunner() { LOGGER.info("ELSE :" + homeDir); } for (File file : homeDir.listFiles()) { + TestNG runner = new TestNG(); + List suitefiles = new ArrayList<>(); if (file.getName().toLowerCase().contains(GlobalConstants.INJICERTIFY)) { + if (file.getName().toLowerCase().contains("prerequisite")) { + BaseTestCase.setReportName(GlobalConstants.INJICERTIFY + "-prerequisite"); + } else { + // if the prerequisite total skipped/failed count is greater than zero + if (EmailableReport.getFailedCount() > 0 || EmailableReport.getSkippedCount() > 0) { +// skipAll = true; + } + BaseTestCase.setReportName(GlobalConstants.INJICERTIFY); + } 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(); + } /** diff --git a/apitest/src/main/java/io/mosip/testrig/apirig/utils/InjiCertifyUtil.java b/apitest/src/main/java/io/mosip/testrig/apirig/utils/InjiCertifyUtil.java index 82f0fac6..dbb190fd 100644 --- a/apitest/src/main/java/io/mosip/testrig/apirig/utils/InjiCertifyUtil.java +++ b/apitest/src/main/java/io/mosip/testrig/apirig/utils/InjiCertifyUtil.java @@ -7,6 +7,7 @@ import com.nimbusds.jose.jwk.RSAKey; import io.mosip.testrig.apirig.dto.TestCaseDTO; +import io.mosip.testrig.apirig.testrunner.MosipTestRunner; import io.mosip.testrig.apirig.testrunner.OTPListener; public class InjiCertifyUtil extends AdminTestUtil { @@ -233,6 +234,10 @@ public static String getKeyWordFromEndPoint(String endPoint) { 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/apitest/testNgXmlFiles/injicertifyPrerequisiteSuite.xml b/apitest/testNgXmlFiles/injicertifyPrerequisiteSuite.xml new file mode 100644 index 00000000..3778b447 --- /dev/null +++ b/apitest/testNgXmlFiles/injicertifyPrerequisiteSuite.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apitest/testNgXmlFiles/injicertifyApi.xml b/apitest/testNgXmlFiles/injicertifySuite.xml similarity index 97% rename from apitest/testNgXmlFiles/injicertifyApi.xml rename to apitest/testNgXmlFiles/injicertifySuite.xml index e5f8de2c..1908ad6a 100644 --- a/apitest/testNgXmlFiles/injicertifyApi.xml +++ b/apitest/testNgXmlFiles/injicertifySuite.xml @@ -8,21 +8,6 @@ - - - - - - - -