ui_tests: add test case to method name in testng report
/*
- * Copyright 2017-2019 EPAM Systems, Inc. (https://www.epam.com/)
+ * Copyright 2017-2020 EPAM Systems, Inc. (https://www.epam.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,11 @@ import com.epam.pipeline.autotests.ao.AuthenticationPageAO;
import com.epam.pipeline.autotests.utils.C;
import com.epam.pipeline.autotests.utils.TestCase;
import org.openqa.selenium.Cookie;
+import org.testng.ITest;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import java.awt.*;
import java.lang.reflect.Method;
@@ -35,7 +37,9 @@ import static com.codeborne.selenide.Selenide.$;
import static com.epam.pipeline.autotests.utils.Utils.sleep;
import static java.util.concurrent.TimeUnit.SECONDS;
-public abstract class AbstractBfxPipelineTest {
+public abstract class AbstractBfxPipelineTest implements ITest {
+
+ private String methodName;
@BeforeClass
public void setUp() {
@@ -73,6 +77,23 @@ public abstract class AbstractBfxPipelineTest {
sleep(3, SECONDS);
}
+ @Override
+ public String getTestName() {
+ return methodName;
+ }
+
+ @BeforeMethod
+ public void setMethodName(Method method, Object[] testData){
+ if (method.isAnnotationPresent(TestCase.class)) {
+ final TestCase testCaseAnnotation = method.getAnnotation(TestCase.class);
+ for (final String testCase : testCaseAnnotation.value()) {
+ methodName = String.format("%s - %s", method.getName(), testCase);
+ }
+ } else {
+ methodName = method.getName();
+ }
+ }
+
@AfterMethod
public void logging(ITestResult result) {
StringBuilder testCasesString = new StringBuilder();
