Skip to content

Commit

Permalink
Migrate selenium-container examples from junit4 to junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
samed-bicer committed Aug 16, 2023
1 parent f5d7a2a commit 7c4ac15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions examples/selenium-container/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.testcontainers:selenium'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import com.example.DemoApplication;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeOptions;
Expand All @@ -13,10 +12,11 @@
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BrowserWebDriverContainer;
import org.testcontainers.containers.BrowserWebDriverContainer.VncRecordingMode;
import org.testcontainers.junit.jupiter.Container;

import java.io.File;
import java.time.Duration;
Expand All @@ -27,15 +27,16 @@
/**
* Simple example of plain Selenium usage.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@org.testcontainers.junit.jupiter.Testcontainers
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = DemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(initializers = SeleniumContainerTest.Initializer.class)
public class SeleniumContainerTest {

@LocalServerPort
private int port;

@Rule
@Container
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions())
.withRecordingMode(VncRecordingMode.RECORD_ALL, new File("build"));
Expand Down

0 comments on commit 7c4ac15

Please sign in to comment.