maven test not running appium studio

446 views Asked by At

I try running my test case using maven project and i want to integrate with jenkins too. but maven not running my test.i already add dependency to appium also. but still not run the test. i using appium studio to make my test case and copy code use based junit................................................

here my code i using java:

package appium;

//package <set your test package>;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.junit.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.logging.Level;

public class appiumtest {

private String reportDirectory = "reports";
private String reportFormat = "xml";
private String testName = "login";
protected AndroidDriver<AndroidElement> driver = null;

DesiredCapabilities dc = new DesiredCapabilities();

@Before
public void setUp() throws MalformedURLException {
    dc.setCapability("reportDirectory", reportDirectory);
    dc.setCapability("reportFormat", reportFormat);
    dc.setCapability("testName", testName);
    dc.setCapability(MobileCapabilityType.UDID, "f5a19fd4");
    dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.pegipegi.android");
    dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".main.activities.SplashActivity");
    driver = new AndroidDriver<AndroidElement>(new URL("http://localhost:4723/wd/hub"), dc);
    driver.setLogLevel(Level.INFO);

}
@Test
public void testlogin() {

    driver.findElement(By.xpath("//*[@contentDescription='Open navigation drawer']")).click();
    driver.findElement(By.xpath("//*[@text='Login / Register']")).click();
    driver.findElement(By.xpath("//*[@id='edit_text_email']")).sendKeys("[email protected]");
    driver.findElement(By.xpath("//*[@id='edit_text_password']")).sendKeys("test12");
    driver.findElement(By.xpath("//*[@text='LOGIN']")).click();
}

@After
public void tearDown() {
    driver.quit();
}
}

her my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>appi</groupId>
  <artifactId>appium</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <repositories>
        <repository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <id>Experitest.repo1</id>
            <name>YourName</name>
            <url>http://repo.experitest.com:8010/Maven2/</url>
            <layout>default</layout>
        </repository>
          </repositories>

     <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>



    <dependency>
    <groupId>com.experitest</groupId>
    <artifactId>seetest-client</artifactId>
    <version>11.0</version>
    </dependency> 

 <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.52.0</version>
        </dependency>

      <dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>4.1.2</version>
    </dependency>


</dependencies>

 <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                          <includes>
            <include>appiumtest.java</include>
          </includes>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>        
</project>  

build log:

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------------< appi:appium >-----------------------------
[INFO] Building appium 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ appium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ appium ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ appium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ appium ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ appium ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.993 s
[INFO] Finished at: 2018-09-26T10:43:20+07:00
[INFO] ------------------------------------------------------------------------
1

There are 1 answers

0
Amit Jain On

If you are using testng.xml then you can use following plugin and this will run testng.xml when you execute command mvn clean install

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <suiteXmlFiles>
                    <!-- TestNG suite XML files -->
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>