Skip to content

Commit 19963f6

Browse files
Merge pull request #315 from telekom/fix/testclass-context
Updated handling of ClassContext name
2 parents 33470cb + bfff6a0 commit 19963f6

37 files changed

+449
-115
lines changed

core/src/main/java/eu/tsystems/mms/tic/testframework/report/model/context/TestContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public ClassContext getClassContext(ITestResult testResult) {
6565
*/
6666
public ClassContext getClassContext(final ITestNGMethod iTestNgMethod) {
6767
final IClass testClass = iTestNgMethod.getTestClass();
68-
return this.pGetClassContext(testClass, testClass.getRealClass().getSimpleName());
68+
// return this.pGetClassContext(testClass, testClass.getRealClass().getSimpleName());
69+
return this.pGetClassContext(testClass, testClass.getRealClass().getName());
6970
}
7071

7172
private synchronized ClassContext pGetClassContext(IClass testClass, String classContextName) {

core/src/main/java/eu/tsystems/mms/tic/testframework/report/utils/DefaultTestNGContextGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class DefaultTestNGContextGenerator implements TestNGContextNameGenerator
2929

3030
@Override
3131
public String getClassContextName(ITestResult testResult) {
32-
return testResult.getTestClass().getRealClass().getSimpleName();
32+
// return testResult.getTestClass().getRealClass().getSimpleName();
33+
return testResult.getTestClass().getRealClass().getName();
3334
}
3435

3536
@Override

docs/src/docs/pageobject/components.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The second parameter is the *root element* of your component (here the `div` ele
4545
----
4646
public class MyPage extends Page {
4747
48-
@Check
4948
MyComponent component = createComponent(MyComponent.class, find(By.id("container")));
49+
5050
}
5151
----
5252

report-ng-tests/src/main/java/io/testerra/report/test/pages/report/sideBarPages/ReportLogsPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void assertMarkedLogLinesContainText(String expectedText) {
6969
if (markedLineParts.list().size() > 0) {
7070
if (!markedLineParts.list()
7171
.stream()
72-
.map(uiElement -> uiElement.expect().text().getActual())
72+
.map(uiElement -> uiElement.waitFor().text().getActual())
7373
.map(String::toUpperCase)
7474
.allMatch(i -> i.contains(expectedText.toUpperCase()))) {
7575
allLogLinesMarkedAsExpected = false;
@@ -87,7 +87,7 @@ public void assertMarkedLogLinesContainTextNoScroll(String expectedText) {
8787

8888
boolean allLogLinesMarkedAsExpected = list
8989
.stream()
90-
.map(uiElement -> uiElement.expect().text().getActual())
90+
.map(uiElement -> uiElement.waitFor().text().getActual())
9191
.map(String::toUpperCase)
9292
.allMatch(i -> i.contains(expectedText.toUpperCase()));
9393

report-ng-tests/src/main/java/io/testerra/report/test/pages/report/sideBarPages/ReportTestsPage.java

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
package io.testerra.report.test.pages.report.sideBarPages;
2323

2424
import eu.tsystems.mms.tic.testframework.pageobjects.Check;
25+
import eu.tsystems.mms.tic.testframework.pageobjects.PreparedLocator;
2526
import eu.tsystems.mms.tic.testframework.pageobjects.UiElement;
2627
import eu.tsystems.mms.tic.testframework.report.Status;
2728
import io.testerra.report.test.pages.AbstractReportPage;
2829
import io.testerra.report.test.pages.ReportSidebarPageType;
2930
import io.testerra.report.test.pages.report.methodReport.AbstractReportMethodPage;
30-
import io.testerra.report.test.pages.report.methodReport.ReportDependenciesTab;
3131
import io.testerra.report.test.pages.report.methodReport.ReportDetailsTab;
32-
import io.testerra.report.test.pages.report.methodReport.ReportSessionsTab;
3332
import io.testerra.report.test.pages.report.methodReport.ReportStepsTab;
3433
import org.openqa.selenium.By;
3534
import org.openqa.selenium.WebDriver;
@@ -54,7 +53,7 @@ public class ReportTestsPage extends AbstractReportPage {
5453
private final String tableRowsLocator = "//tbody//tr";
5554
private final UiElement tableRows = pageContent.find(By.xpath(tableRowsLocator));
5655

57-
private final String methodLinkLocator = "//tbody//tr//td//a[text()='%s']";
56+
PreparedLocator preparedMethodLinkLocator = LOCATE.prepare("//a[contains(@route-href, 'method') and text()='%s']");
5857
private final UiElement tableHead = pageContent.find(By.xpath(".//thead"));
5958

6059
public void checkPriorityMessagesPreviewForTest(String methodName, String[] priorityMessages) {
@@ -93,20 +92,16 @@ public int index() {
9392
}
9493
}
9594

96-
9795
public ReportTestsPage(WebDriver driver) {
9896
super(driver);
9997
}
10098

101-
public List<UiElement> getColumnWithoutHead(int columnNumber) {
99+
private List<UiElement> getColumnWithoutHead(final int columnNumber) {
102100
List<UiElement> column = new ArrayList<>();
103-
for (UiElement row : tableRows.list().stream().collect(Collectors.toList())) {
104-
column.add(row.find(By.xpath("//td")).list().stream().collect(Collectors.toList()).get(columnNumber));
105-
}
101+
tableRows.list().forEach(row -> column.add(row.find(By.xpath("//td[" + (columnNumber + 1) + "]"))));
106102
return column;
107103
}
108104

109-
110105
public List<UiElement> getColumnWithoutHead(TestsTableEntry tableEntry) {
111106
return getColumnWithoutHead(tableEntry.index());
112107
}
@@ -137,13 +132,19 @@ public void pageLoaded() {
137132
verifyReportPage(ReportSidebarPageType.TESTS);
138133
}
139134

140-
141-
public void assertMethodColumnContainsCorrectMethods(String filter) {
135+
public void assertMethodColumnMatchesFilter(String filter) {
142136
getColumnWithoutHead(TestsTableEntry.METHOD)
143137
.forEach(uiElement -> uiElement.expect().text().contains(filter).is(true,
144138
String.format("Every found method [%s] should contain: %s", uiElement.expect().text().getActual(), filter)));
145139
}
146140

141+
public void assertMethodColumnContainsCorrectMethods(List<String> methodNames) {
142+
getColumnWithoutHead(TestsTableEntry.METHOD).forEach(uiElement -> {
143+
String methodFromTable = uiElement.find(By.tagName("a")).waitFor().text().getActual();
144+
Assert.assertTrue(methodNames.contains(methodFromTable), String.format("Testmethod %s should not shown with the given filter.", methodFromTable));
145+
});
146+
}
147+
147148
public void assertClassColumnContainsCorrectClasses(String expectedClass) {
148149
getColumnWithoutHead(TestsTableEntry.CLASS)
149150
.forEach(uiElement -> uiElement.expect().text().is(expectedClass, String.format(
@@ -235,15 +236,6 @@ public ReportStepsTab navigateToStepsTab(final String methodName, final Status s
235236
return createPage(ReportStepsTab.class);
236237
}
237238

238-
public ReportSessionsTab navigateToSessionsTab(final String methodName, final Status status) {
239-
240-
final String methodNameLinkLocator = tableRowsLocator.concat("[.//a[text()= '" + status.title + "']]//a[text()= '" + methodName + "']");
241-
final UiElement methodNameLink = find(By.xpath(methodNameLinkLocator));
242-
methodNameLink.click();
243-
244-
return createPage(ReportSessionsTab.class);
245-
}
246-
247239
public ReportDetailsTab navigateToDetailsTab(final String methodName, final Status status) {
248240

249241
final String methodNameLinkLocator = tableRowsLocator.concat("[.//a[text()= '" + status.title + "']]//a[text()= '" + methodName + "']");
@@ -253,54 +245,27 @@ public ReportDetailsTab navigateToDetailsTab(final String methodName, final Stat
253245
return createPage(ReportDetailsTab.class);
254246
}
255247

256-
public ReportDependenciesTab navigateToDependenciesTab(final String methodName, final Status status) {
257-
258-
final String methodNameLinkLocator = tableRowsLocator.concat("[.//a[text()= '" + status.title + "']]//a[text()= '" + methodName + "']");
259-
final UiElement methodNameLink = find(By.xpath(methodNameLinkLocator));
260-
methodNameLink.click();
261-
262-
return createPage(ReportDependenciesTab.class);
263-
}
264-
265248
public <T extends AbstractReportMethodPage> T navigateToMethodDetails(final Class<T> reportPageClass, String methodName) {
266-
UiElement subElement = pageContent.find(By.xpath(String.format(methodLinkLocator, methodName)));
249+
UiElement subElement = pageContent.find(this.preparedMethodLinkLocator.with(methodName));
267250
subElement.click();
268251

269252
return createPage(reportPageClass);
270253
}
271254

272255
public ReportStepsTab navigateToStepsTab(String methodName) {
273-
274-
UiElement subElement = pageContent.find(By.xpath(String.format(methodLinkLocator, methodName)));
256+
UiElement subElement = pageContent.find(this.preparedMethodLinkLocator.with(methodName));
275257
subElement.click();
276258

277259
return createPage(ReportStepsTab.class);
278260
}
279261

280-
public ReportSessionsTab navigateToSessionsTab(String methodName) {
281-
282-
UiElement subElement = pageContent.find(By.xpath(String.format(methodLinkLocator, methodName)));
283-
subElement.click();
284-
285-
return createPage(ReportSessionsTab.class);
286-
}
287-
288262
public ReportDetailsTab navigateToDetailsTab(String methodName) {
289-
290-
UiElement subElement = pageContent.find(By.xpath(String.format(methodLinkLocator, methodName)));
263+
UiElement subElement = pageContent.find(this.preparedMethodLinkLocator.with(methodName));
291264
subElement.click();
292265

293266
return createPage(ReportDetailsTab.class);
294267
}
295268

296-
public ReportDependenciesTab navigateToDependenciesTab(String methodName) {
297-
298-
UiElement subElement = pageContent.find(By.xpath(String.format(methodLinkLocator, methodName)));
299-
subElement.click();
300-
301-
return createPage(ReportDependenciesTab.class);
302-
}
303-
304269
public ReportTestsPage clickConfigurationMethodsSwitch() {
305270
configurationMethodsSwitch.click();
306271
return createPage(ReportTestsPage.class);
@@ -337,4 +302,4 @@ public ReportTestsPage selectTestStatus(Status status) {
337302
public ReportTestsPage selectClassName(String label) {
338303
return selectDropBoxElement(this.testClassSelect, label, ReportTestsPage.class);
339304
}
340-
}
305+
}

report-ng-tests/src/test/java/io/testerra/report/test/AbstractReportTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import eu.tsystems.mms.tic.testframework.common.DefaultPropertyManager;
2626
import eu.tsystems.mms.tic.testframework.core.server.Server;
2727
import eu.tsystems.mms.tic.testframework.core.testpage.TestPage;
28-
import eu.tsystems.mms.tic.testframework.logging.Loggable;
2928
import eu.tsystems.mms.tic.testframework.report.Report;
3029
import eu.tsystems.mms.tic.testframework.utils.FileUtils;
3130
import io.testerra.report.test.pages.AbstractReportPage;
@@ -37,13 +36,10 @@
3736
import java.io.File;
3837
import java.net.BindException;
3938

40-
import static eu.tsystems.mms.tic.testframework.testing.PageFactoryProvider.PAGE_FACTORY;
41-
import static eu.tsystems.mms.tic.testframework.testing.WebDriverManagerProvider.WEB_DRIVER_MANAGER;
42-
4339
/**
4440
* Abstract test class for tests based on static test site resources
4541
*/
46-
public abstract class AbstractReportTest extends AbstractTest implements Loggable {
42+
public abstract class AbstractReportTest extends AbstractTest {
4743

4844
private final static File serverRootDir = FileUtils.getResourceFile("reports");
4945
private final static Server server = new Server(serverRootDir);
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package io.testerra.report.test;
22

33
import eu.tsystems.mms.tic.testframework.constants.Browsers;
4+
import eu.tsystems.mms.tic.testframework.logging.Loggable;
5+
import eu.tsystems.mms.tic.testframework.testing.AssertProvider;
6+
import eu.tsystems.mms.tic.testframework.testing.PageFactoryProvider;
47
import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
58
import eu.tsystems.mms.tic.testframework.testing.WebDriverManagerProvider;
69
import eu.tsystems.mms.tic.testframework.useragents.ChromeConfig;
710
import org.testng.annotations.BeforeSuite;
811

9-
public abstract class AbstractTest extends TesterraTest {
12+
public abstract class AbstractTest extends TesterraTest implements
13+
Loggable,
14+
WebDriverManagerProvider,
15+
PageFactoryProvider,
16+
AssertProvider {
1017

1118
@BeforeSuite(alwaysRun = true)
1219
public void configureChromeOptions() {
13-
WebDriverManagerProvider.WEB_DRIVER_MANAGER.setUserAgentConfig(Browsers.chromeHeadless, (ChromeConfig) options -> options.addArguments("--disable-dev-shm-usage"));
20+
WEB_DRIVER_MANAGER.setUserAgentConfig(Browsers.chromeHeadless, (ChromeConfig) options -> options.addArguments("--disable-dev-shm-usage"));
1421
}
1522
}

report-ng-tests/src/test/java/io/testerra/report/test/AbstractTestSitesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import eu.tsystems.mms.tic.testframework.core.server.Server;
2626
import eu.tsystems.mms.tic.testframework.logging.Loggable;
27+
import eu.tsystems.mms.tic.testframework.testing.AssertProvider;
2728
import eu.tsystems.mms.tic.testframework.testing.PageFactoryProvider;
2829
import eu.tsystems.mms.tic.testframework.testing.WebDriverManagerProvider;
2930
import eu.tsystems.mms.tic.testframework.utils.FileUtils;
@@ -37,7 +38,7 @@
3738
/**
3839
* Abstract test class for tests based on static test site resources
3940
*/
40-
public abstract class AbstractTestSitesTest extends AbstractTest implements WebDriverManagerProvider, PageFactoryProvider, Loggable {
41+
public abstract class AbstractTestSitesTest extends AbstractTest implements WebDriverManagerProvider, PageFactoryProvider, AssertProvider, Loggable {
4142

4243
protected static Server server = new Server(FileUtils.getResourceFile("testsites"));
4344
private String exclusiveSessionId;

report-ng-tests/src/test/java/io/testerra/report/test/TestDataProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public static Object[][] dataProviderForTestsWithoutFailureAspect() {
111111
};
112112
}
113113

114-
@DataProvider(parallel = true)
114+
@DataProvider(parallel = false)
115115
public static Object[][] dataProviderForPreTestMethodsWithStatusFailed() {
116116
return new Object[][]{
117-
{new TestData("testAssertCollector", "AssertCollector.fail", "AssertCollector.fail")},
117+
{new TestData("testAssertCollector", "ASSERT.fail(\"failed1\")", "ASSERT.fail(\"failed2\")")},
118118
{new TestData("test_failedPageNotFound", "PAGE_FACTORY.createPage(NonExistingPage.class, WEB_DRIVER_MANAGER.getWebDriver());")},
119119
{new TestData("test_Failed", "Assert.fail")},
120120
{new TestData("test_Failed_WithScreenShot", "Assert.fail")}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Testerra
3+
*
4+
* (C) 2023, Martin Großmann, Telekom MMS GmbH, Deutsche Telekom AG
5+
*
6+
* Deutsche Telekom AG and all other contributors /
7+
* copyright owners license this file to you under the Apache
8+
* License, Version 2.0 (the "License"); you may not use this
9+
* file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
package io.testerra.report.test.pretest_status.classContext;
22+
23+
import eu.tsystems.mms.tic.testframework.annotations.TestClassContext;
24+
import org.testng.annotations.Test;
25+
26+
/**
27+
* Created on 2023-03-21
28+
*
29+
* @author mgn
30+
*/
31+
@TestClassContext(name = "ClassContextInheritedClasses")
32+
public class GenerateClassContextChildClassTest extends GenerateClassContextParentClassTest {
33+
34+
@Test
35+
public void testTestMethodInChildClasses() {
36+
}
37+
38+
}

0 commit comments

Comments
 (0)