Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit for jdi-light-mobile template #1

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Jdi-mobile-template.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 JDI Testing tools

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
Repository for jdi-light mobile template
This template contains jdi-light-mobile Android tests

How to launch android tests

1) Stable requirements:
Java 8, Maven 3.6.3, TestNG 6.14.3, Appium 1.18.3, Android 10 <br>

2) Install Appium & Android studio for Android emulator

3) Install test-app on your emulator

4) _mvn clean install_ - to install project dependencies

5) Run tests by Maven command:
`mvn clean test site -Dsuite.xml.file=src/test/resources/androidApps.xml`

6) Get allure report in target/site package
Binary file added allure.tgz
Binary file not shown.
156 changes: 156 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?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>

<version>1.3.8</version>
<artifactId>jdi-light-mobile-tests</artifactId>
<name>Tests: JDI Mobile</name>
<groupId>com.epam.jdi</groupId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<driver>chrome</driver>
<!--driver>firefox</driver-->
<allure.testng>2.13.2</allure.testng>
<allure.maven>2.10.0</allure.maven>
<jetty.version>9.4.12.RC2</jetty.version>
<aspectj.version>1.9.6</aspectj.version>
<suite.xml.file>src/test/resources/android10SystemTests.xml</suite.xml.file>
<suite.xml.file>src/test/resources/android11SystemTests.xml</suite.xml.file>
<suite.xml.file>src/test/resources/androidApps.xml</suite.xml.file>
<suite.xml.file>src/test/resources/androidAppsEspresso.xml</suite.xml.file>
<suite.xml.file>src/test/resources/iosApps.xml</suite.xml.file>
<suite.xml.file>src/test/resources/webMobileTests.xml</suite.xml.file>
</properties>

<dependencies>
<!--JDI-->
<dependency>
<groupId>com.epam.jdi</groupId>
<artifactId>jdi-light-html</artifactId>
<version>1.3.8</version>
</dependency>
<dependency>
<groupId>com.epam.jdi</groupId>
<artifactId>jdi-light-mobile</artifactId>
<version>1.3.8</version>
</dependency>

<!--Allure config in parent-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.testng}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.2</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.17.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--Allure reporting config in parent-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suite.xml.file}</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<properties>
<property>
<name>listener</name>
<value>io.qameta.allure.testng.AllureTestNg</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven}</version>
</plugin>
</plugins>

<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<!-- Allure reporting config in parent-->
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.epam.jdi.light.mobile;

import com.epam.jdi.light.mobile.driver.MobileDriverData;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Properties;

import static com.epam.jdi.light.settings.WebSettings.logger;
import static java.lang.ClassLoader.getSystemResource;

public class AllurePropertiesGenerator {

private static final String ENVIRONMENT_PROPERTIES_FILENAME = "environment.properties";
private static final String ALLURE_RESULTS_DIR = "allure-results";
private static final String PROPERTIES_FORMAT = "%s=%s";
public static final String DRIVER = "driver";
public static final String DEVICE_NAME_PROPERTY = "deviceName";
public static final String PLATFORM_NAME_PROPERTY = "platformName";
public static final String APPIUM_URL_PROPERTY = "driver.remote.url";
boolean initiated = false;

public void createAllureProperties() {
if (initiated) {
return;
}

String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
String propsPath = rootPath + "test.properties";
Properties appProps = new Properties();
try (FileInputStream propStream = new FileInputStream(propsPath)) {
appProps.load(propStream);
} catch (IOException e) {
logger.error("Error during read test.properties file from %s. %s", propsPath, e);
}

List<String> properties = Arrays.asList(
formatProperties(DRIVER, "Chrome", appProps),
formatProperties(DEVICE_NAME_PROPERTY, "unset in test.properties", appProps),
formatProperties(PLATFORM_NAME_PROPERTY, "Chrome", appProps),
formatProperties(APPIUM_URL_PROPERTY, "-", appProps)
);

try {
Path allureResults = Paths.get(getSystemResource("").toURI()).getParent();
allureResults = Paths.get(allureResults.toAbsolutePath().toString(),
ALLURE_RESULTS_DIR, ENVIRONMENT_PROPERTIES_FILENAME);
if (!Files.exists(allureResults.getParent())) {
Files.createDirectories(allureResults.getParent());
}
logger.info(String.format("allure prop file path: %s", allureResults.toAbsolutePath()));
Files.write(allureResults, properties, StandardCharsets.UTF_8);
} catch (Exception e) {
logger.error("Can not create property file for allure results.", e);
logger.toLog(e.toString());
}
initiated = true;

}

private String formatProperties(String propertyName, String defValue, Properties appProps) {
String propertyValue = appProps.getProperty(propertyName);
if (propertyValue == null) {
if ("android".equalsIgnoreCase(appProps.getProperty(DRIVER))) {
propertyValue = MobileDriverData.CAPABILITIES_FOR_ANDROID.get(propertyName);
} else {
propertyValue = MobileDriverData.CAPABILITIES_FOR_IOS.get(propertyName);
}
}
return String.format(PROPERTIES_FORMAT, propertyName, Objects.isNull(propertyValue) ? defValue : propertyValue);
}

}
Loading