Skip to content

Commit

Permalink
Test runner support to run jar MOSIP-29698 (mosip#898)
Browse files Browse the repository at this point in the history
* MOSIP-29698

* Test runner support to run jar MOSIP-29698

* Update TestData.json

Signed-off-by: neeharikatech <[email protected]>

---------

Signed-off-by: neeharikatech <[email protected]>
Signed-off-by: Tilak Puli <[email protected]>
  • Loading branch information
neeharikatech authored and tilak-puli committed Oct 11, 2023
1 parent 6e44a83 commit e3523a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,52 @@
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<String> suitefiles = new ArrayList<String>();
//// 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();
}
/*
<suite name="All Test Suite" parallel="tests" thread-count="2">
<listeners>
<listener class-name="listeners.Listeners"/>
</listeners>
<test verbose="2" preserve-order="true" name="android">
<parameter name="platformName" value="ANDROID"/>
*/


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";
else
return "IDE";
}

}

public static void startTestRunner() {
File homeDir = null;
TestNG runner = new TestNG();
List<String> 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();
}}
2 changes: 1 addition & 1 deletion injitest/src/main/resources/TestData.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit e3523a0

Please sign in to comment.