I am trying to create a Java project with Junit5 tests in IntelliJ IDEA 2023.1.1 (Ultimate Edition).
Java version: Corretto-11.0.19.7.1
Following is my project structure
myJavaProject/
├── build.gradle.kts
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
├── main
│ ├── java
│ │ └── org
│ │ └── example
│ │ └── Main.java
│ └── resources
└── test
├── java
│ └── org
│ └── example
└── resources
Following is my build.gradle.kts
file
plugins {
id("java")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
}
tasks.test {
useJUnitPlatform()
systemProperty("junit.jupiter.conditions.deactivate", "*")
systemProperty("junit.jupiter.extensions.autodetection.enabled", true)
systemProperty("junit.jupiter.testinstance.lifecycle.default", "per_class")
}
I am trying to create a test for Main.java file as shown here - https://www.jetbrains.com/help/idea/create-tests.html
When creating a test through UI, I don't see Junit5 as one of the option in the drop down menu. I verified that the correct directories are marked TestSourcesRoot, SourcesRoot, Resources Root and Test Resources Root.
I am stuck with this issue for a while. Any help is appreciated. Please let me know if you need more info. from my side.
Thanks in advance.
If you are only receiving the options as shown in the image while creating a test class through UI, your IntelliJ does not have the Junit plugin, or its in a disabled state.
If you enable the junit plugin. it will give you Junit, Junit5 options in UI