Skip to content

Commit

Permalink
MOSIP-29934
Browse files Browse the repository at this point in the history
Signed-off-by: Anup Nehe <[email protected]>
  • Loading branch information
anup-nehe committed Oct 25, 2023
1 parent 4a269c7 commit e2f4030
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
6 changes: 0 additions & 6 deletions injitest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@
<artifactId>java-client</artifactId>
<version>9.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
Expand Down
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();
}}

0 comments on commit e2f4030

Please sign in to comment.