Skip to content

Commit

Permalink
Rework test name listener to correct name in allure report
Browse files Browse the repository at this point in the history
  • Loading branch information
mialeska committed Apr 23, 2024
1 parent 0a67f58 commit 05c8306
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 72 deletions.
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
@@ -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.

Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
import aquality.appium.mobile.application.AqualityServices;
import aquality.appium.mobile.template.modules.CustomMobileModule;
import aquality.appium.mobile.template.testng.utilities.ModuleFactory;
import aquality.appium.mobile.template.testng.utilities.TestNameListener;
import aquality.appium.mobile.template.utilities.IScreenshotProvider;
import aquality.selenium.core.localization.ILocalizedLogger;
import com.google.inject.Inject;
import io.qameta.allure.Allure;
import org.assertj.core.api.Assertions;
import org.assertj.core.description.Description;
import org.testng.ITestContext;
import org.testng.annotations.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice;

import java.io.ByteArrayInputStream;
import java.util.function.Consumer;

@Guice(moduleFactory = ModuleFactory.class)
@Listeners(TestNameListener.class)
public class BaseTest {
@Inject
IScreenshotProvider screenshotProvider;
@Inject
ILocalizedLogger localizedLogger;
@Inject
CustomMobileModule customBrowserModule;

private Application application;

@BeforeTest
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package aquality.appium.mobile.template.utilities;

import aquality.appium.mobile.application.AqualityServices;
import io.qameta.allure.listener.TestLifecycleListener;
import io.qameta.allure.model.Parameter;
import io.qameta.allure.model.TestResult;

import java.util.List;

public class AllureListener implements TestLifecycleListener {

public void afterTestStart(TestResult result) {
List<Parameter> oldParameters = result.getParameters();
Parameter parameter = new Parameter();
parameter.setName("platform");
parameter.setValue(AqualityServices.getApplicationProfile().getPlatformName().toString());
oldParameters.add(parameter);
result.setHistoryId(result.getHistoryId() + parameter.getValue());
String oldName = result.getFullName();
result.setFullName(String.format("%s: %s", oldName, parameter.getValue()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aquality.appium.mobile.template.utilities.AllureListener

0 comments on commit 05c8306

Please sign in to comment.