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

TestNG template project with allure report #24

Merged
merged 11 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 13 additions & 0 deletions .github/workflows/test-with-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- 'aquality-appium-mobile-template/**'
- 'aquality-appium-mobile-template-cucumber/**'
- 'aquality-selenium-template-testng/**'
mialeska marked this conversation as resolved.
Show resolved Hide resolved
- 'scripts/**'
push:
branches: [ master ]
Expand All @@ -23,6 +24,8 @@ on:
jobs:
build-and-test-android:
env:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
ANDROID_PROFILE: Nexus 6
Expand Down Expand Up @@ -60,6 +63,10 @@ jobs:
profile: ${{ env.ANDROID_PROFILE }}
script: mvn test -DisRemote=true -DplatformName=android

- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}

- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
Expand All @@ -69,6 +76,8 @@ jobs:

build-and-test-ios:
env:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
IOS_SIM_MODEL: iPhone 8
Expand Down Expand Up @@ -109,6 +118,10 @@ jobs:
id: maven_tests
run: mvn test -DisRemote=true -DplatformName=ios

- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}

- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
Expand Down
2 changes: 1 addition & 1 deletion aquality-appium-mobile-template-cucumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber5-jvm</artifactId>
<version>2.13.3</version>
<version>${allure.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Feature: Demo
Background:
Given Allure test name has been updated by the platform parameter

@demo
Scenario: I try to login with invalid credentials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package aquality.appium.mobile.template.cucumber.hooks;

import aquality.appium.mobile.application.AqualityServices;
import aquality.appium.mobile.template.configuration.Configuration;
import io.cucumber.java.After;

import static aquality.appium.mobile.application.AqualityServices.getApplication;

public class ApplicationHooks {

@After(order = 0)
public void closeApplication() {
if (AqualityServices.isApplicationStarted()) {
AqualityServices.getApplication().quit();
getApplication().terminateApp(Configuration.getBundleId());
getApplication().quit();
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package aquality.appium.mobile.template.cucumber.objectfactory;

import aquality.appium.mobile.application.AqualityServices;
import aquality.appium.mobile.template.modules.CustomMobileModule;
import aquality.appium.mobile.template.modules.ServiceModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
Expand All @@ -13,7 +15,7 @@ public class CustomObjectFactory implements ObjectFactory {
private final Injector injector;

public CustomObjectFactory() {
CustomMobileModule mobileModule = new CustomMobileModule(AqualityServices::getApplication);
CustomMobileModule mobileModule = new CustomMobileModule();
AqualityServices.initInjector(mobileModule);
this.injector = Guice.createInjector(Stage.PRODUCTION, CucumberModules.createScenarioModule(),
new ServiceModule(), mobileModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package aquality.appium.mobile.template.cucumber.stepdefinitions;

import aquality.appium.mobile.screens.screenfactory.IScreenFactory;
import aquality.appium.mobile.template.screens.Alert;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

import javax.inject.Inject;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class AlertSteps {

private final Alert alert;

@Inject
public AlertSteps(IScreenFactory screenFactory) {
alert = screenFactory.getScreen(Alert.class);
}

@Then("'{}' alert appears")
public void alertAppears(String alertMessage) {
assertTrue(alert.state().waitForDisplayed(), "Alert appeared");
assertEquals(alert.getMessage(), alertMessage, "Alert message is correct");
}

@When("I accept the alert")
public void acceptAlert() {
alert.tapOk();
}
}

This file was deleted.

58 changes: 58 additions & 0 deletions aquality-appium-mobile-template-testng/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>
<parent>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-appium-mobile-java-template-project</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>

<artifactId>aquality-appium-mobile-template-testng</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-appium-mobile-template</artifactId>
<version>1.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package aquality.appium.mobile.template.testng.constants;

import lombok.experimental.UtilityClass;

@UtilityClass
public class AlertMessages {
public static final String INVALID_CREDENTIALS = "Invalid login credentials, please try again";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package aquality.appium.mobile.template.testng.constants;

import lombok.experimental.UtilityClass;

@UtilityClass
public class ViewNames {
public static final String LOGIN_SCREEN = "Login Screen";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aquality.appium.mobile.template.testng.steps;

import aquality.appium.mobile.template.screens.Alert;
import io.qameta.allure.Step;

import javax.inject.Inject;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class AlertSteps {

@Inject
private Alert alert;

@Step("'{alertMessage}' alert appears")
public void checkAlertAppears(String alertMessage) {
assertTrue(alert.state().waitForDisplayed(), "Alert appeared");
assertEquals(alert.getMessage(), alertMessage, "Alert message is correct");
}

@Step("I accept the alert")
public void acceptAlert() {
alert.tapOk();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package aquality.appium.mobile.template.testng.steps;

import aquality.appium.mobile.template.screens.chooseview.ChooseViewScreen;
import io.qameta.allure.Step;

import javax.inject.Inject;

public class ChooseViewSteps {

@Inject
private ChooseViewScreen chooseViewScreen;

@Step("I open '{viewName}' view")
public void openView(String viewName) {
chooseViewScreen.openView(viewName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package aquality.appium.mobile.template.testng.steps;

import aquality.appium.mobile.template.models.LoginModel;
import aquality.appium.mobile.template.screens.login.LoginScreen;
import io.qameta.allure.Step;

import javax.inject.Inject;

import static org.testng.Assert.assertTrue;

public class LoginSteps {

@Inject
private LoginScreen loginScreen;

@Step("I log in with data:")
public void fillInLoginForm(LoginModel loginModel) {
loginScreen.setUsername(loginModel.getUsername())
.setPassword(loginModel.getPassword())
.tapLogin();
}

@Step("Login Screen is opened")
public void checkLoginScreenIsOpened() {
assertTrue(loginScreen.state().waitForDisplayed(), "Login Screen is opened");
}

@Step("I save Login Screen dump")
public void saveLoginScreenDump() {
loginScreen.dump().save();
}

@Step("Login Screen dump is different")
public void checkLoginScreenDumpIsDifferent() {
assertTrue(loginScreen.dump().compare() > 0, "The form dump should differ");
}
}
Loading
Loading