Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-36505 | Split the Testng report into pre-requisite and functional test #1343

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,6 +50,7 @@ public class MosipTestRunner {

public static String jarUrl = MosipTestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath();
public static List<String> languageList = new ArrayList<>();
public static boolean skipAll = false;

/**
* C Main method to start mosip test execution
Expand Down Expand Up @@ -136,7 +138,6 @@ public static void suiteSetup(String runType) {
DBManager.executeDBQueries(ResidentConfigManager.getMASTERDbUrl(), ResidentConfigManager.getMasterDbUser(),
ResidentConfigManager.getMasterDbPass(), ResidentConfigManager.getMasterDbSchema(),
getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt");
BaseTestCase.setReportName(GlobalConstants.RESIDENT);
AdminTestUtil.copyResidentTestResource();
BaseTestCase.otpListener = new OTPListener();
BaseTestCase.otpListener.run();
Expand All @@ -159,8 +160,6 @@ private static void setLogLevels() {
*/
public static void startTestRunner() {
File homeDir = null;
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();
String os = System.getProperty("os.name");
LOGGER.info(os);
if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
Expand All @@ -172,14 +171,26 @@ public static void startTestRunner() {
LOGGER.info("ELSE :" + homeDir);
}
for (File file : homeDir.listFiles()) {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();
if (file.getName().toLowerCase().contains(GlobalConstants.RESIDENT)) {
if (file.getName().toLowerCase().contains("prerequisite")) {
BaseTestCase.setReportName(GlobalConstants.RESIDENT + "-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.RESIDENT);
}
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.testng.SkipException;

import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.MosipTestRunner;

public class ResidentUtil extends AdminTestUtil {

Expand All @@ -12,6 +13,10 @@ public class ResidentUtil 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);
}
Expand Down
21 changes: 21 additions & 0 deletions api-test/testNgXmlFiles/residentPrerequisiteSuite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Resident Prerequisite Suite">
<!-- Passing Group as parmeter unsing "testType" Possible Groups are: smoke
regression smokeAndRegression -->
<listeners>
<listener class-name="io.mosip.testrig.apirig.report.EmailableReport"/>
</listeners>


<test name="AddIdentity">
<parameter name="ymlFile"
value="resident/AddIdentity/AddIdentity.yml" />
<parameter name="prerequisite" value="Yes" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.AddIdentity" />
</classes>
</test>

</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
</listeners>


<test name="AddIdentity">
<parameter name="ymlFile"
value="resident/AddIdentity/AddIdentity.yml" />
<parameter name="prerequisite" value="Yes" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.AddIdentity" />
</classes>
</test>
<test name="GenerateVID">
<parameter name="ymlFile"
value="resident/GenerateVID/createGenerateVID.yml" />
Expand Down
Loading