From e3523a0828f9114b745850c1c630984a7fd7c543 Mon Sep 17 00:00:00 2001 From: neeharikatech <76684248+neeharikatech@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:28:31 +0530 Subject: [PATCH] Test runner support to run jar MOSIP-29698 (#898) * MOSIP-29698 * Test runner support to run jar MOSIP-29698 * Update TestData.json Signed-off-by: neeharikatech <76684248+neeharikatech@users.noreply.github.com> --------- Signed-off-by: neeharikatech <76684248+neeharikatech@users.noreply.github.com> Signed-off-by: Tilak Puli --- .../test/mob/inji/driver/TestRunner.java | 72 ++++++------------- injitest/src/main/resources/TestData.json | 2 +- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/injitest/src/main/java/io/mosip/test/mob/inji/driver/TestRunner.java b/injitest/src/main/java/io/mosip/test/mob/inji/driver/TestRunner.java index da1e4d70f6..b7456e56e5 100644 --- a/injitest/src/main/java/io/mosip/test/mob/inji/driver/TestRunner.java +++ b/injitest/src/main/java/io/mosip/test/mob/inji/driver/TestRunner.java @@ -5,77 +5,33 @@ import java.util.ArrayList; import java.util.List; -import io.mosip.test.mob.inji.listeners.Listeners; -import io.mosip.test.mob.inji.testcases.*; -import io.mosip.test.mob.inji.utils.TestDataReader; import org.testng.TestListenerAdapter; import org.testng.TestNG; public class TestRunner { -public static String jarUrl = TestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + public static String jarUrl = TestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath(); static TestListenerAdapter tla = new TestListenerAdapter(); - - static TestNG testNg; - + public static void main(String[] args) throws Exception { - testNg=new TestNG(); - System.out.println("testng file started"); - String listExcludedGroups=TestDataReader.readData("setExcludedGroups"); - testNg.setExcludedGroups(listExcludedGroups); - testNg.setPreserveOrder(true); - testNg.setVerbose(2); -//// List suitefiles = new ArrayList(); -//// suitefiles.add("testng.xml"); -// testNg.setTestSuites(suitefiles); - // testNg.setTestClasses(new Class[]{Listeners.class}); - - testNg.setTestClasses(new Class[] { - - ActivateVcTest.class, - ChangeLanguageTest.class, - DeletingVcTest.class, - GenerateUinOrVidTest.class, - PinVcTest.class, - UnlockWithPasscodeTest.class, - VcDownloadAndVerifyUsingUinTest.class, - VcDownloadAndVerifyUsingVidTest.class, - VerifyHelpPageTest.class, - VerifyHistoryTest.class, - VerifyWelcomePagesTest.class - - - }); - testNg.run(); - + startTestRunner(); } - /* - - - - - - - */ - + public static String getResourcePath() { if (checkRunType().equalsIgnoreCase("JAR")) { return new File(jarUrl).getParentFile().getAbsolutePath().toString()+"/resources/"; } else if (checkRunType().equalsIgnoreCase("IDE")) { - String path = System.getProperty("user.dir"); + String path =System.getProperty("user.dir") + System.getProperty("path.config"); - - // String path = new File(TestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath() - // .toString(); if (path.contains("test-classes")) path = path.replace("test-classes", "classes"); return path; } return "Global Resource File Path Not Found"; } - + public static String checkRunType() { if (TestRunner.class.getResource("TestRunner.class").getPath().toString().contains(".jar")) return "JAR"; @@ -83,4 +39,18 @@ public static String checkRunType() { return "IDE"; } -} + + public static void startTestRunner() { + File homeDir = null; + TestNG runner = new TestNG(); + List suitefiles = new ArrayList<>(); + + homeDir = new File(System.getProperty("user.dir") + "/testng.xml"); + + suitefiles.add(homeDir.getAbsolutePath()); + + runner.setTestSuites(suitefiles); + System.getProperties().setProperty("testng.outpur.dir", "testng-report"); + runner.setOutputDirectory("testng-report"); + runner.run(); + }} diff --git a/injitest/src/main/resources/TestData.json b/injitest/src/main/resources/TestData.json index bd82154bac..d1c2f3a106 100644 --- a/injitest/src/main/resources/TestData.json +++ b/injitest/src/main/resources/TestData.json @@ -8,7 +8,7 @@ "status": "Valid", "generatedOn": "9/5/2023", "aid": "10001100660000620230714065538", - "setExcludedGroups":"AVT", + "setExcludedGroups":"AVT,PVT", "androidAppPath":"D:/GITINJI/inji/injitest/apps/android/Inji_latest.apk", "androidDevice": "Pixel_6a_API_30" }