-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anup Nehe <[email protected]>
- Loading branch information
Showing
2 changed files
with
47 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 47 additions & 39 deletions
86
injitest/src/main/java/io/mosip/test/mob/inji/driver/TestRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
package io.mosip.test.mob.inji.driver; | ||
|
||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.testng.TestListenerAdapter; | ||
import org.testng.TestNG; | ||
|
||
|
||
public class TestRunner { | ||
public static String jarUrl = TestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath(); | ||
|
||
static TestListenerAdapter tla = new TestListenerAdapter(); | ||
|
||
public static void main(String[] args) throws Exception { | ||
startTestRunner(); | ||
} | ||
|
||
public static String getResourcePath() { | ||
if (checkRunType().equalsIgnoreCase("JAR")) | ||
return (new File(jarUrl)).getParentFile().getAbsolutePath().toString() + "/resources/"; | ||
if (checkRunType().equalsIgnoreCase("IDE")) { | ||
String path = System.getProperty("user.dir") + System.getProperty("path.config"); | ||
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"; | ||
return "IDE"; | ||
} | ||
|
||
public static void startTestRunner() { | ||
File homeDir = null; | ||
TestNG runner = new TestNG(); | ||
List<String> suitefiles = new ArrayList<>(); | ||
String os = System.getProperty("os.name"); | ||
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(); | ||
} | ||
} | ||
public static String jarUrl = TestRunner.class.getProtectionDomain().getCodeSource().getLocation().getPath(); | ||
static TestListenerAdapter tla = new TestListenerAdapter(); | ||
|
||
|
||
public static void main(String[] args) throws Exception { | ||
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") + System.getProperty("path.config"); | ||
|
||
|
||
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(); | ||
}} |