bug6127: removed junit "vintage" from target platform after JUnit5 migration

This commit is contained in:
Axel Uhl
2025-06-05 17:23:16 +02:00
parent 8d787f7cfc
commit d0a64e7005
31 changed files with 10915 additions and 6160 deletions
@@ -14,7 +14,7 @@
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.sap.sailing.selenium.test"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit5"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.sap.sailing.selenium.test"/>
@@ -21,7 +21,7 @@ import org.openqa.selenium.remote.RemoteWebDriver;
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
class ScreenShotRule implements TestWatcher, BeforeEachCallback, AfterEachCallback {
public class ScreenShotRule implements TestWatcher, BeforeEachCallback, AfterEachCallback {
private static final String NOT_SUPPORTED_IMAGE = "/com/sap/sailing/selenium/resources/not-supported.png"; //$NON-NLS-1$
private static final String ATTACHMENT_FORMAT = "[[ATTACHMENT|%s]]"; //$NON-NLS-1$
/**
@@ -1,50 +0,0 @@
package com.sap.sailing.selenium.core;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolver;
import com.sap.sailing.selenium.core.TestEnvironmentConfiguration.DriverDefinition;
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
/**
* Can resolve a parameter of type {@link TestEnvironment} to an environment that uses the given
* {@link DriverDefinition} to create a Selenium WebDriver instance. It can be returned as a additional extension by the
* {@link SeleniumTestInvocationProvider}, one per web driver discovered in the {@link TestEnvironmentConfiguration}.
* <p>
*
* Furthermore, being a {@link BeforeEachCallback}, it will create the environment, and if the test being executed is an
* instance of {@link AbstractSeleniumTest}, sets the environment on the test instance using its
* {@link AbstractSeleniumTest#setEnvironment(TestEnvironment)} method.
*
* @author Axel Uhl (d043530)
*
*/
class SeleniumParameterResolver implements ParameterResolver, BeforeEachCallback {
private final DriverDefinition driverDef;
private TestEnvironment environment;
SeleniumParameterResolver(DriverDefinition driverDef) {
this.driverDef = driverDef;
}
@Override
public boolean supportsParameter(ParameterContext pc, ExtensionContext ec) {
return pc.getParameter().getType() == TestEnvironment.class;
}
@Override
public Object resolveParameter(ParameterContext pc, ExtensionContext ec) {
return environment;
}
@Override
public void beforeEach(ExtensionContext context) throws Exception {
Object testInstance = context.getRequiredTestInstance();
environment = TestEnvironmentFactory.create(driverDef);
if (testInstance instanceof AbstractSeleniumTest) {
((AbstractSeleniumTest) testInstance).setEnvironment(environment);
}
}
}
@@ -0,0 +1,24 @@
package com.sap.sailing.selenium.core;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* Use this annotation on test methods in subclasses of {@link AbstractSeleniumTest} to indicate that they are Selenium
* test cases. This will set the {@link SeleniumTestInvocationProvider} as the test invocation provider for the test
* method, ensuring it will get executed for each web driver definition, with the {@link TestEnvironment} being injected
* into the test by the additional extension {@link TestEnvironmentInjector} provided by the test contexts produced by
* the invocation provider.
*
* @author Axel Uhl (d043530)
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@TestTemplate
@ExtendWith(SeleniumTestInvocationProvider.class)
public @interface SeleniumTestCase {}
@@ -0,0 +1,32 @@
package com.sap.sailing.selenium.core;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
import com.sap.sailing.selenium.core.TestEnvironmentConfiguration.DriverDefinition;
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
/**
* Creates the {@link TestEnvironment} based on the {@link DriverDefinition} passed to its constructor, and if the test
* being executed is an instance of {@link AbstractSeleniumTest}, sets the environment on the test instance using its
* {@link AbstractSeleniumTest#setEnvironment(TestEnvironment)} method.
*
* @author Axel Uhl (d043530)
*
*/
class SeleniumTestEnvironmentInjector implements TestInstancePostProcessor {
private final DriverDefinition driverDef;
private TestEnvironment environment;
SeleniumTestEnvironmentInjector(DriverDefinition driverDef) {
this.driverDef = driverDef;
}
@Override
public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception {
environment = TestEnvironmentFactory.create(driverDef);
if (testInstance instanceof AbstractSeleniumTest) {
((AbstractSeleniumTest) testInstance).setEnvironment(environment);
}
}
}
@@ -10,13 +10,14 @@ import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
import com.sap.sailing.selenium.core.TestEnvironmentConfiguration.DriverDefinition;
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
/**
* Used to extend the {@link SeleniumTestTemplate} annotation which in turn is used to extend the
* base class of all Selenium tests, {@link AbstractSeleniumTest}. This provider produces
* text invocation contexts, one for each {@link TestEnvironmentConfiguration#getDriverDefinitions() driver definition}
* found in the test environment configuration.
* Used to extend the {@link SeleniumTestCase} annotation which in turn is used to mark the test methods of all Selenium
* tests declared in subclasses of {@link AbstractSeleniumTest}. This provider produces test invocation contexts, one
* for each {@link TestEnvironmentConfiguration#getDriverDefinitions() driver definition} found in the test environment
* configuration. These contexts provide a test instance-specific extension of type {@link SeleniumTestEnvironmentInjector}
* which is in particular a {@link TestInstancePostProcessor} that creates and injects a {@link TestEnvironment} created
* for the driver definition known by the parameter resolver.<p>
*
* @author Axel Uhl (d043530)
*
@@ -49,7 +50,7 @@ public class SeleniumTestInvocationProvider implements TestTemplateInvocationCon
@Override
public List<Extension> getAdditionalExtensions() {
return Arrays.asList(new SeleniumParameterResolver(driverDefinition));
return Arrays.asList(new SeleniumTestEnvironmentInjector(driverDefinition));
}
}
}
@@ -5,13 +5,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@TestTemplate
@ExtendWith(SeleniumTestInvocationProvider.class)
@ExtendWith(ScreenShotRule.class)
public @interface SeleniumTestTemplate {
public @interface UseSeleniumExtensions {
}
@@ -22,7 +22,7 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.html5.WebStorage;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.sap.sailing.selenium.core.SeleniumTestTemplate;
import com.sap.sailing.selenium.core.UseSeleniumExtensions;
import com.sap.sailing.selenium.core.TestEnvironment;
import com.sap.sailing.selenium.core.WindowManager;
import com.sap.sailing.selenium.pages.PageObject;
@@ -37,7 +37,7 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
* @author
* D049941
*/
@SeleniumTestTemplate
@UseSeleniumExtensions
public abstract class AbstractSeleniumTest {
private static final Logger logger = Logger.getLogger(AbstractSeleniumTest.class.getName());
@@ -12,10 +12,10 @@ import javax.xml.bind.DatatypeConverter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.sap.sailing.selenium.core.SeleniumTestCase;
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
@@ -56,7 +56,6 @@ public class TestAutoPlay extends AbstractSeleniumTest {
}
private void initTrackingForBmwCupRace(AdminConsolePage adminConsole) {
TrackableRaceDescriptor trackableRace = new TrackableRaceDescriptor(BMW_CUP_EVENT, String.format(BMW_RACE, 1),
BMW_CUP_BOAT_CLASS);
TrackedRaceDescriptor trackedRace = new TrackedRaceDescriptor(BMW_CUP_REGATTA, BMW_CUP_BOAT_CLASS,
@@ -78,7 +77,7 @@ public class TestAutoPlay extends AbstractSeleniumTest {
details.linkRace(new RaceDescriptor(BMW_CUP_RACE_NAME, "Default", false, false, 0), trackedRace);
}
@Test
@SeleniumTestCase
public void testSixtyInchAutoPlayStartup() {
AdminConsolePage adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
EventConfigurationPanelPO events = adminConsole.goToEvents();
@@ -101,7 +100,7 @@ public class TestAutoPlay extends AbstractSeleniumTest {
assertEquals("There are no further races starting soon", nextUpText);
}
@Test
@SeleniumTestCase
public void testClassicAutoPlayStartup() {
AdminConsolePage adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
EventConfigurationPanelPO events = adminConsole.goToEvents();