OS Ubuntu 22.04
Jenkins 2.375.3
Maven 3.6.3
I have this code in java:
package prueba;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import java.net.URL;
import java.time.Duration;
import org.junit.Test;
import java.net.MalformedURLException;
public class Prueba {
@Test
public void main () throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Redmi");
caps.setCapability("uid", "2856d148");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.1.2");
caps.setCapability("appPackage", "com.miui.calculator");
caps.setCapability("appActivity", "com.miui.calculator.cal.CalculatorActivity");
AndroidDriver driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(50));
driver.findElement(By.id("com.miui.calculator:id/btn_7_s")).click();
driver.findElement(By.id("com.miui.calculator:id/btn_plus_s")).click();
driver.findElement(By.id("com.miui.calculator:id/btn_8_s")).click();
driver.findElement(By.id("com.miui.calculator:id/btn_equal_s")).click();
driver.quit();
}
}
It works fine when I execute it like JUnit Test. It opens the calculator of my mobile phone and make 7+8 = 15
I’ve created a Maven project in jenkins but when I run it show this
Running as SYSTEM
Ejecutando.en el espacio de trabajo /var/lib/jenkins/workspace/apium
Parsing POMs
Established TCP socket on 39473
[testapium] $ java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.14.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar:/usr/share/maven/conf/logging jenkins.maven3.agent.Maven35Main /usr/share/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-3077.vd69cf116da_6f.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.14.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.14.jar 39473
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /var/lib/jenkins/workspace/apium/testapium/pom.xml clean test
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------< testappium:testapium >------------------------
[INFO] Building testapium 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] — maven-clean-plugin:2.5:clean (default-clean) @ testapium —
[INFO] Deleting /var/lib/jenkins/workspace/apium/testapium/target
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ testapium —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:3.10.1:compile (default-compile) @ testapium —
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/apium/testapium/target/classes
[INFO]
[INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ testapium — [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ testapium —
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] — maven-surefire-plugin:3.0.0-M8:test (default-test) @ testapium —
[INFO] Using auto detected provider org.apache.maven.surefire.testng.TestNGProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.557 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[JENKINS] Guardando informes de test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.736 s
[INFO] Finished at: 2023-02-21T10:13:31+01:00
[INFO] ------------------------------------------------------------------------ Esperando a que Jenkins finalice de recopilar datos
[JENKINS] Archiving /var/lib/jenkins/workspace/apium/testapium/pom.xml to testappium/testapium/0.0.1-SNAPSHOT/testapium-0.0.1-SNAPSHOT.pom
channel stopped
Finished: SUCCESS
Why Tests run: 0?
This is the content of the 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Appium</groupId>
<artifactId>AppiumTest1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M9</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M9</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>