14. Parallel Execution with JUnit 5 and TestNG

JUnit 5 Parallel Execution Configuration

# src/test/resources/junit-platform.properties
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
public class BaseTest {
    protected Playwright playwright;
    protected Browser browser;
    protected Page page;

@BeforeEach
void setUp() {
playwright = Playwright.create();
browser = playwright.chromium().launch();
page = browser.newPage();
}

@AfterEach
void tearDown() {
playwright.close();
}
}

Task

  • Implement calculateWorkerThreads:
  • 1. Accept int cpuCores.
  • 2. Return Math.max(1, cpuCores - 1).
πŸ’‘Common doubts
Did you like the problem?
Lesson 14 of 18
Java
Loading code editor…
Next