From: Kai Moritz Date: Wed, 22 Jan 2020 11:49:25 +0000 (+0100) Subject: WIP X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=3dcb574d91d50c6bd1dceb8d6a403cb01d833908;p=demos%2Fspring-boot WIP --- diff --git a/src/test/java/de/juplo/demo/DemoControllerIT.java b/src/test/java/de/juplo/demo/DemoControllerIT.java index 8678a87..84eabea 100644 --- a/src/test/java/de/juplo/demo/DemoControllerIT.java +++ b/src/test/java/de/juplo/demo/DemoControllerIT.java @@ -3,26 +3,21 @@ package de.juplo.demo; 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) { } diff --git a/src/test/java/de/juplo/demo/WebDriverExtension.java b/src/test/java/de/juplo/demo/WebDriverExtension.java index 25de95f..a2c5d0c 100644 --- a/src/test/java/de/juplo/demo/WebDriverExtension.java +++ b/src/test/java/de/juplo/demo/WebDriverExtension.java @@ -3,6 +3,8 @@ package de.juplo.demo; 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; @@ -14,7 +16,7 @@ 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; @@ -24,4 +26,20 @@ public class WebDriverExtension implements BeforeEachCallback { 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; + } }