Skip to content

Commit a2e59c6

Browse files
Shanoj ThekkanShanoj Thekkan
Shanoj Thekkan
authored and
Shanoj Thekkan
committed
modified test
1 parent 93f729e commit a2e59c6

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

Test_proj/src/test/java/com/testing/proj/Test_proj/AppTest.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
import java.io.File;
44
import java.io.IOException;
55
import java.net.URL;
6+
import java.util.HashMap;
7+
import java.util.Map;
68
import java.util.concurrent.TimeUnit;
79

10+
import org.apache.commons.exec.CommandLine;
11+
import org.apache.commons.exec.DefaultExecuteResultHandler;
12+
import org.apache.commons.exec.DefaultExecutor;
813
import org.openqa.selenium.By;
914
import org.openqa.selenium.remote.DesiredCapabilities;
1015
import org.testng.annotations.AfterSuite;
@@ -30,16 +35,33 @@ public class AppTest
3035
public static By findIcon = By.xpath("//*[@class='android.support.v7.app.ActionBar$Tab'][1]");
3136
public static AppiumDriver driver = null;
3237
// public static AppiumServiceBuilder service;
33-
38+
39+
3440
public static AppiumDriverLocalService service=null;
3541
public static String AppiumNodeFilePath ="/usr/local/bin/node";
3642
public static String AppiumJavaScriptServerFile = "/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js";
3743
@BeforeTest
3844
// public static void setup(String pVer, String pName, String appLocation, String dName)
3945
public static void setup() throws IOException {
40-
41-
stopAppiumServer();
42-
startAppiumServer();
46+
47+
//Runtime.getRuntime().exec("/bin/bash export ANDROID_HOME=/Users/shanojthekkan/Library/Android/sdk/");
48+
49+
CommandLine command = new CommandLine("/usr/local/bin/node");
50+
command.addArgument("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js", false);
51+
command.addArgument("--address", false);
52+
command.addArgument("0.0.0.0");
53+
command.addArgument("--port", false);
54+
command.addArgument("4723");
55+
command.addArgument("--no-reset", true);
56+
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
57+
DefaultExecutor executor = new DefaultExecutor();
58+
executor.setExitValue(1);
59+
executor.execute(command, resultHandler);
60+
61+
62+
63+
// stopAppiumServer();
64+
// startAppiumServer();
4365

4466
File appDir = new File("resources");
4567
File app = new File(appDir, "Officeworks.apk");
@@ -65,6 +87,8 @@ public static void setup() throws IOException {
6587
public static void startAppiumServer() throws IOException {
6688

6789
System.out.println("Starting Appium Server ......");
90+
91+
6892

6993
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File(AppiumNodeFilePath)).withAppiumJS(
7094
new File(AppiumJavaScriptServerFile)));
@@ -103,6 +127,6 @@ public void testsample() throws InterruptedException {
103127
@AfterTest
104128
public static void teardown() throws IOException {
105129
driver.quit();
106-
stopAppiumServer();
130+
// stopAppiumServer();
107131
}
108132
}

Test_proj/test-output/testng-results.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
<testng-results skipped="0" failed="0" total="1" passed="1">
33
<reporter-output>
44
</reporter-output>
5-
<suite name="Suite" duration-ms="31516" started-at="2017-05-15T11:30:19Z" finished-at="2017-05-15T11:30:50Z">
5+
<suite name="Suite" duration-ms="43328" started-at="2017-05-16T05:08:31Z" finished-at="2017-05-16T05:09:14Z">
66
<groups>
77
</groups>
8-
<test name="Test" duration-ms="31516" started-at="2017-05-15T11:30:19Z" finished-at="2017-05-15T11:30:50Z">
8+
<test name="Test" duration-ms="43328" started-at="2017-05-16T05:08:31Z" finished-at="2017-05-16T05:09:14Z">
99
<class name="com.testing.proj.Test_proj.AppTest">
10-
<test-method status="PASS" signature="setup()[pri:0, instance:com.testing.proj.Test_proj.AppTest@69ea3742]" name="setup" is-config="true" duration-ms="28694" started-at="2017-05-15T21:30:19Z" finished-at="2017-05-15T21:30:48Z">
10+
<test-method status="PASS" signature="setup()[pri:0, instance:com.testing.proj.Test_proj.AppTest@6adede5]" name="setup" is-config="true" duration-ms="40730" started-at="2017-05-16T15:08:31Z" finished-at="2017-05-16T15:09:12Z">
1111
<reporter-output>
1212
</reporter-output>
1313
</test-method> <!-- setup -->
14-
<test-method status="PASS" signature="testsample()[pri:0, instance:com.testing.proj.Test_proj.AppTest@69ea3742]" name="testsample" duration-ms="1952" started-at="2017-05-15T21:30:48Z" finished-at="2017-05-15T21:30:49Z">
14+
<test-method status="PASS" signature="testsample()[pri:0, instance:com.testing.proj.Test_proj.AppTest@6adede5]" name="testsample" duration-ms="1854" started-at="2017-05-16T15:09:12Z" finished-at="2017-05-16T15:09:14Z">
1515
<reporter-output>
1616
</reporter-output>
1717
</test-method> <!-- testsample -->
18-
<test-method status="PASS" signature="teardown()[pri:0, instance:com.testing.proj.Test_proj.AppTest@69ea3742]" name="teardown" is-config="true" duration-ms="859" started-at="2017-05-15T21:30:50Z" finished-at="2017-05-15T21:30:50Z">
18+
<test-method status="PASS" signature="teardown()[pri:0, instance:com.testing.proj.Test_proj.AppTest@6adede5]" name="teardown" is-config="true" duration-ms="726" started-at="2017-05-16T15:09:14Z" finished-at="2017-05-16T15:09:14Z">
1919
<reporter-output>
2020
</reporter-output>
2121
</test-method> <!-- teardown -->

0 commit comments

Comments
 (0)