import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-import org.springframework.test.web.reactive.server.WebTestClient;
+import org.testcontainers.containers.BrowserWebDriverContainer;
/**
* Integration-Test for the {@link DemoController}.
* @author Kai Moritz
*/
-@SpringBootTest(webEnvironment = RANDOM_PORT, classes = DemoController.class)
+@SpringBootTest(webEnvironment = RANDOM_PORT)
@Slf4j
public class DemoControllerIT
{
- @Autowired
- WebTestClient client;
-
-
@Test
- void testSubmit()
+ void testSubmit(BrowserWebDriverContainer chrome)
{
}
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 org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testcontainers.containers.BrowserWebDriverContainer;
* {@link https://www.testcontainers.org/modules/webdriver_containers/ Testcontainers}.
* @author Kai Moritz
*/
-public class WebDriverExtension implements BeforeEachCallback
+public class WebDriverExtension implements BeforeEachCallback, ParameterResolver
{
BrowserWebDriverContainer chrome;
{
chrome = new BrowserWebDriverContainer().withCapabilities(DesiredCapabilities.chrome());
}
+
+ @Override
+ public boolean supportsParameter(
+ ParameterContext parameterContext,
+ ExtensionContext extensionContext)
+ {
+ return parameterContext.getParameter().getType() == BrowserWebDriverContainer.class;
+ }
+
+ @Override
+ public Object resolveParameter(
+ ParameterContext parameterContext,
+ ExtensionContext extensionContext)
+ {
+ return chrome;
+ }
}