I'm trying to migration from JUnit4 to JUnit5 and I have a @Rule
annotation and I don't exactly know how I can replace this. I tried @ExtendWith
but not working for me.
My code with JUnit 4 annotations:
@Rule
public TextReport textReport = new TextReport();
@Rule
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions());
Edit: The part of my current code is:
@Testcontainers
@ExtendWith(TextReportExtension.class)
public class TestBase {
@Container
public static BrowserWebDriverContainer chrome = new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions());
@Before
public void setup() {
RemoteWebDriver driver = chrome.getWebDriver();
System.out.println("VNC Address: " + chrome.getVncAddress());
All test classes extends TestBase. And I get an error:
java.lang.IllegalStateException: Mapped port can only be obtained after the container is started