Do I need to configure Surefire or the JUnit Platform?
No. New Maven and Gradle projects are created with JUnit 5 and the test runner already configured.
New Maven and Gradle projects come with JUnit 5. Put tests in src/test/java, click the gutter marker or press Ctrl+Shift+F10, and the results appear in a tree with messages and clickable stack traces.
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class CalculatorTest {
@Test
void addsTwoNumbers() {
assertEquals(5, Calculator.add(2, 3));
}
@Test
void multipliesTwoNumbers() {
assertEquals(6, Calculator.multiply(2, 3));
}
} Click the green marker next to the class or press Ctrl+Shift+F10 with the caret inside it.
Built on the tools Java and Kotlin developers already trust
Write and run JUnit 5 tests online. Run one test, a class or the whole suite from the gutter and read the results in a tree — Maven or Gradle, Java or Kotlin.
New Maven and Gradle projects include JUnit 5, and the test live template writes a test method for you.
Run a single method, a class or the whole suite with Run All Tests.
Passed, failed and skipped tests are grouped by class, with failure messages and stack traces you can click.
Tests run through Maven Surefire or the Gradle test task, exactly as they would on a build server.
In an older project, put the caret on an unresolved org.junit import and press Alt+Enter.
Tests in src/test/kotlin run the same way, with the same results tree.
Test classes live in src/test/java or src/test/kotlin of a Maven or Gradle project and need JUnit on the test classpath. Plain IntelliJ-style projects run programs but not test suites; create a Maven or Gradle project for tests.
A failed assertion shows the expected and actual values in the tree. Click a line of the stack trace to open the test or the code under test at that line, fix it and run the same test again.
No. New Maven and Gradle projects are created with JUnit 5 and the test runner already configured.
Yes. Use the gutter marker next to the method or press Ctrl+Shift+F10 with the caret inside it.
Reproduce it from an application configuration and set breakpoints in the code under test; the debugger runs Application and JAR configurations.
No. Tests run in the same isolated sandbox as programs, without network ports or internet access.
Open a tab and start coding
Free account, JDK 8–27, Maven, Gradle and Kotlin — nothing to install.
Create a free account