Reputation: 6220
After importing my project into Intellij and getting it to build successfully, I am trying to run some of my project's tests. I navigate to the test file and select Run -> Run. However, this does not run my tests, just opens a small "Edit Configurations" window, as the attached photo shows.
And, when I select Edit Configurations as prompted, JUnit is not to be found. The window is shown below.
What do I need to do to run the tests?
Upvotes: 6
Views: 37379
Reputation: 21
For me it was also an issue with my pom.xml. After checking Junit5-samples pom. I noticed the test plugin was missing. So I only needed to add:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
You may also want to check if your pom contains:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
Upvotes: 2
Reputation: 13350
For me this was an issue with my pom.xml
and using JUnit5
with IntelliJ
because my tests were not getting detected and it said 0 executed 0 skipped
etc.
Here's what I added to my pom.xml
to get JUnit5
tests to run in IntelliJ
:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
And here's the dependencies I added:
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert-core</artifactId>
<version>2.0M10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0-M1</version>
</dependency>
</dependencies>
Upvotes: 1
Reputation: 89
makre sure you IDEA have installed the Junit plugins and Junit jar in your classpath:
and then just click this place to run test case:
Upvotes: 0
Reputation: 893
Try to click on your project and click on Run 'All Tests' . After that, go to 'Edit Configurations..' and make sure you are using -ea
value on VM Options area.
Upvotes: 0