mercredi 30 septembre 2020

Test don't run when i run maven test with appium java project

i would see and test appium for my project and i finish setup a new maven project with appium and cucumber, but i have this issue: when i run maven test i see ever zero test run and i don't understand where is the issue.

JDK installed on my local machine:JDK-15 path of jdk bin and maven bin is in my windows path variable

This is my POM file: https://github.com/silv3ri0/test-appium-java/blob/master/com.qa/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>qa.mobile</groupId>
  <artifactId>com.qa</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.version>3.6.0</maven.compiler.version>
    <maven.compiler.source>7</maven.compiler.source>
    <maven.compiler.target>7</maven.compiler.target>
  </properties>
  
  <dependencies>
  
    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.3.0</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.0.0</version>
        <scope>compile</scope>
    </dependency>
    
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>6.7.0</version>
        <scope>test</scope>
    </dependency>
        
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>6.6.0</version>
        <scope>test</scope>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>6.5.0</version>
    </dependency>
    
</dependencies>
  
  <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>            
        </plugins>        
    </build>  
</project>

MyRunnerTestClass: https://github.com/silv3ri0/test-appium-java/blob/master/com.qa/src/test/java/com/qa/runners/MyRunnerTest.java

    package com.qa.runners;
    
    import org.testng.annotations.Test;
    
    import io.cucumber.junit.Cucumber;
    import io.cucumber.junit.CucumberOptions;
    import io.cucumber.junit.CucumberOptions.SnippetType;
    
    //@RunWith(Cucumber.class)
    @CucumberOptions(plugin = {"pretty", "html:target/cucumber", "summary"}
                                ,features = {"src/test/resources"}
                                ,glue = {"com.qa.stepdef"}/*tags = {"@appium"}*/)
   @Test
    public class MyRunnerTest {
    
    }

StedefClass: https://github.com/silv3ri0/test-appium-java/blob/master/com.qa/src/test/java/com/qa/stepdef/MissguidedStepDef.java

package com.qa.stepdef;

import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import utility.Hook;

public class MissguidedStepDef {
    
    private AppiumDriver driver;
    
    public MissguidedStepDef() {
        this.driver = (AppiumDriver) Hook.getDriver();
    }
    
    @Given("^i navigate the shop$")
    public void iNavigateTheShop() {
        // Write code here that turns the phrase above into concrete actions
        Assert.assertTrue(driver.findElement(By.xpath("//*[@text='Accessibility']")).isDisplayed());
        
    }

Hooks Class: https://github.com/silv3ri0/test-appium-java/blob/master/com.qa/src/test/java/utility/Hook.java

package utility;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.cucumber.java.After;
import io.cucumber.java.Before;

public class Hook {

    private static AppiumDriver driver;
    
    @Before
    public void setUpAppium() throws MalformedURLException
    {
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("platformVersion", "11");
        desiredCapabilities.setCapability("deviceName", "any device name");
        desiredCapabilities.setCapability("automationName", "UiAutomator2");
        desiredCapabilities.setCapability("avd", "Pixel_3_API_30");
        desiredCapabilities.setCapability("appPackage", "com.poqstudio.app.platform.missguided");
        desiredCapabilities.setCapability("appActivity", "com.poqstudio.app.platform.presentation.countrySwitcher.view.CountrySwitcherSelectCountryActivity");
        desiredCapabilities.setCapability("app", "C:\\projectappium/Missguided_v14.3.0.1_apkpure.com.apk");

        URL url = new URL("http://127.0.0.1:4723/wd/hub");

        driver = new AndroidDriver(url, desiredCapabilities);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        
        
    }
    
    @After
    public void tearDown()
    {
        driver.quit();
    }
    
    public static WebDriver getDriver()
    {
        return driver;
    }}

Feature file: https://github.com/silv3ri0/test-appium-java/blob/master/com.qa/src/test/resources/AddToBag.feature

Feature: Test add to bag
Scenario: Show register form after add to bag
    Given i navigate the shop
    And select clearence category
    And select seven item from search result
    And add to bag item
    When go to the select pay 
    Then sign in is displayed

Can someone help me? For me for now it's important to verify at least first step of my feature file working fine.

Any idea about this issue?

Thanks in advance, Silverio

Aucun commentaire:

Enregistrer un commentaire