Skip to content

Commit

Permalink
Revert "Merge branch '322-bug-browser-is-not-started-for-after-method…
Browse files Browse the repository at this point in the history
…-if-its-declared-in-different-class-than-the-test-itself' into #330-improvement-stabilize-unit-tests"

This reverts commit 19c6a57, reversing
changes made to 99666f4.
  • Loading branch information
oomelianchuk committed Dec 23, 2024
1 parent 5cca259 commit fa68a51
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public void run(Supplier<Throwable> afterMethodInvocation, Method after, boolean

// if browserConfiguration is null, the browser should not be started for this method and browserTag and
// browserRunner are therefore not required
BrowserMethodData browserTag = browserConfiguration != null ? BrowserData.addKeepBrowserOpenInformation(browserConfiguration.getBrowserTag(),
after.getDeclaringClass(), after)
BrowserMethodData browserTag = browserConfiguration != null ? BrowserData.addKeepBrowserOpenInformation(browserConfiguration.getBrowserTag(), after)
: null;
BrowserRunner browserRunner = browserTag != null ? new BrowserRunner(browserTag, after.getName()) : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void run(Supplier<Throwable> beforeMethodInvocation, Method before, boole

// if browserConfiguration is null, the browser should not be started for this method and browserTag and
// browserRunner are therefore not required
BrowserMethodData browserTag = browserConfiguration != null ? BrowserData.addKeepBrowserOpenInformation(browserConfiguration.getBrowserTag(),
before.getDeclaringClass(), before)
BrowserMethodData browserTag = browserConfiguration != null ? BrowserData.addKeepBrowserOpenInformation(browserConfiguration.getBrowserTag(), before)
: null;
BrowserRunner browserRunner = browserTag != null ? new BrowserRunner(browserTag, before.getName()) : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ public class BrowserData extends Data

private List<RandomBrowsers> classRandomBrowsersAnnotation;

private Class<?> testClass;

private static final String SYSTEM_PROPERTY_BROWSERDEFINITION = "browserdefinition";

public BrowserData(Class<?> testClass)
{
this();
this.testClass = testClass;
initClassAnnotationsFor(testClass);
}

Expand Down Expand Up @@ -201,15 +198,15 @@ else if (!classRandomBrowsersAnnotation.isEmpty() && methodBrowsers.isEmpty())
{
return browsers.stream()
.filter(browserTag -> systemBrowserFilter.contains(browserTag))
.map(browserTag -> addKeepBrowserOpenInformation(browserTag, testClass, testMethod))
.map(browserTag -> addKeepBrowserOpenInformation(browserTag, testMethod))
.collect(Collectors.toList());
}
return browsers.stream()
.map(browserTag -> addKeepBrowserOpenInformation(browserTag, testClass, testMethod))
.map(browserTag -> addKeepBrowserOpenInformation(browserTag, testMethod))
.collect(Collectors.toList());
}

public static BrowserMethodData addKeepBrowserOpenInformation(String browserTag, Class<?> testClass, Method method)
public static BrowserMethodData addKeepBrowserOpenInformation(String browserTag, Method method)
{
List<KeepBrowserOpen> methodKeepBrowserOpenAnnotations = getAnnotations(method, KeepBrowserOpen.class);
List<KeepBrowserOpen> classKeepBrowserOpenAnnotations = getAnnotations(method.getDeclaringClass(), KeepBrowserOpen.class);
Expand Down Expand Up @@ -247,6 +244,7 @@ public static BrowserMethodData addKeepBrowserOpenInformation(String browserTag,
}
}
boolean junit5 = method.getAnnotation(NeodymiumTest.class) != null;
Class<?> testClass = method.getDeclaringClass();
List<Method> afterMethodsWithTestBrowser = List.of(testClass.getMethods()).stream()
.filter(classMethod -> (junit5 ? classMethod.getAnnotation(AfterEach.class)
: classMethod.getAnnotation(After.class)) != null)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
package com.xceptance.neodymium.junit4.testclasses.browser.inheritance;

import org.junit.Assert;
import org.junit.runner.RunWith;

import com.xceptance.neodymium.common.browser.Browser;
import com.xceptance.neodymium.junit4.NeodymiumRunner;
import com.xceptance.neodymium.junit5.NeodymiumTest;
import com.xceptance.neodymium.junit5.tests.NeodymiumWebDriverTest;
import com.xceptance.neodymium.util.Neodymium;

@Browser("Chrome_1024x768")
@Browser("Chrome_1500x1000")
@RunWith(NeodymiumRunner.class)
public abstract class BrowserParent
{
@NeodymiumTest
public void testParent()
{
Assert.assertNotNull(Neodymium.getDriver());
NeodymiumWebDriverTest.assertWebDriverAlive(Neodymium.getDriver());
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package com.xceptance.neodymium.junit5.testclasses.browser.inheritance;

import org.junit.Assert;

import com.xceptance.neodymium.common.browser.Browser;
import com.xceptance.neodymium.junit5.NeodymiumTest;
import com.xceptance.neodymium.junit5.tests.NeodymiumWebDriverTest;
import com.xceptance.neodymium.util.Neodymium;

@Browser("Chrome_1024x768")
@Browser("Chrome_1500x1000")
public abstract class BrowserParent
{
@NeodymiumTest
public void testParent()
{
Assert.assertNotNull(Neodymium.getDriver());
NeodymiumWebDriverTest.assertWebDriverAlive(Neodymium.getDriver());
}

}

0 comments on commit fa68a51

Please sign in to comment.