Any one know why when I run mvn clean test -Dos=android
it doesn't find any tests to run? It runs find if I use the built in Cucumber or JUnit runner in Intellij. I am using Appium and Java 8.
Here are my files and folder structure
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>App</groupId>
<artifactId>Mobile-Automation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<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>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.10.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.10.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>26.0.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
CucumberTestRunner.java
package runner;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features", glue = {"stepdefs"}, plugin = {"pretty", "html:target/cucumber-html-report.html"})
public class CucumberTestRunner {
public CucumberTestRunner(String[] args){}
}
TestBase.java
package runner;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import pageobjects.LoginPage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;
public class TestBase {
public static AppiumDriver driver;
public static LoginPage loginPage;
static Properties props = new Properties();
public static void androidSetUp() throws MalformedURLException {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream("decivecapabilities.properties")){
props.load(inputStream);
} catch (Exception e) {e.printStackTrace();}
DesiredCapabilities androidCaps = new DesiredCapabilities();
androidCaps.setCapability("deviceName", props.getProperty("android.capability.deviceName"));
androidCaps.setCapability("udid", props.getProperty("android.capability.udid"));
androidCaps.setCapability("platformName", props.getProperty("android.capability.platformName"));
androidCaps.setCapability("platformVersion", props.getProperty("android.capability.platformVersion"));
androidCaps.setCapability("automationName", props.getProperty("android.capability.automationName"));
androidCaps.setCapability("appPackage", props.getProperty("android.capability.appPackage"));
androidCaps.setCapability("appActivity", props.getProperty("android.capability.appActivity"));
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), androidCaps);
}
public static void iosSetUp() throws MalformedURLException {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream("decivecapabilities.properties")){
props.load(inputStream);
} catch (Exception e) {e.printStackTrace();}
DesiredCapabilities iosCaps = new DesiredCapabilities();
iosCaps.setCapability("deviceName", props.getProperty("ios.capability.deviceName"));
iosCaps.setCapability("udid", props.getProperty("ios.capability.udid"));
iosCaps.setCapability("platformName", props.getProperty("ios.capability.platformName"));
iosCaps.setCapability("platformVersion", props.getProperty("ios.capability.platformVersion"));
iosCaps.setCapability("automationName", props.getProperty("ios.capability.automationName"));
//iosCaps.setCapability("app", "app-path");
driver = new IOSDriver(new URL("http://localhost:4723/wd/hub"), iosCaps);
}
public static void pageObjectInit(){
loginPage = new LoginPage(driver);
}
public static void tearDown(){
if (driver != null){
driver.quit();
}
}
}
Any insight is appreciated, and I can add post more files if needed.
By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:
**/Test*.java
- includes all of its subdirectories and all Java filenames that start with "Test".**/*Test.java
- includes all of its subdirectories and all Java filenames that end with "Test".**/*Tests.java
- includes all of its subdirectories and all Java filenames that end with "Tests".**/*TestCase.java
- includes all of its subdirectories and all Java filenames that end with "TestCase".https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
By convention tests executed by Maven should end with "Test". So your class should be named RunCucumberTest
.