|
1 | 1 | import com.example.DemoApplication; |
2 | | -import org.junit.Rule; |
3 | | -import org.junit.Test; |
4 | | -import org.junit.runner.RunWith; |
| 2 | +import org.junit.jupiter.api.Test; |
| 3 | +import org.junit.jupiter.api.extension.ExtendWith; |
5 | 4 | import org.openqa.selenium.By; |
6 | 5 | import org.openqa.selenium.WebElement; |
7 | 6 | import org.openqa.selenium.chrome.ChromeOptions; |
|
13 | 12 | import org.springframework.context.ApplicationListener; |
14 | 13 | import org.springframework.context.ConfigurableApplicationContext; |
15 | 14 | import org.springframework.test.context.ContextConfiguration; |
16 | | -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 15 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
17 | 16 | import org.testcontainers.Testcontainers; |
18 | 17 | import org.testcontainers.containers.BrowserWebDriverContainer; |
19 | 18 | import org.testcontainers.containers.BrowserWebDriverContainer.VncRecordingMode; |
| 19 | +import org.testcontainers.junit.jupiter.Container; |
20 | 20 |
|
21 | 21 | import java.io.File; |
22 | 22 | import java.time.Duration; |
|
27 | 27 | /** |
28 | 28 | * Simple example of plain Selenium usage. |
29 | 29 | */ |
30 | | -@RunWith(SpringJUnit4ClassRunner.class) |
| 30 | +@org.testcontainers.junit.jupiter.Testcontainers |
| 31 | +@ExtendWith(SpringExtension.class) |
31 | 32 | @SpringBootTest(classes = DemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) |
32 | 33 | @ContextConfiguration(initializers = SeleniumContainerTest.Initializer.class) |
33 | 34 | public class SeleniumContainerTest { |
34 | 35 |
|
35 | 36 | @LocalServerPort |
36 | 37 | private int port; |
37 | 38 |
|
38 | | - @Rule |
| 39 | + @Container |
39 | 40 | public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer() |
40 | 41 | .withCapabilities(new ChromeOptions()) |
41 | 42 | .withRecordingMode(VncRecordingMode.RECORD_ALL, new File("build")); |
|
0 commit comments