lundi 1 mars 2021

IntelliJ JUnit - Maven imports all annotations except @Test

Maven imports everything within the org.junit.jupiter.api package properly except the @Test annotation.

CalculatorTest.class

pom.xml

Almost every file of the imported org.junit.jupiter.api package

You can see at the screenshots above that:

  • I've marked the src/test/java directory as a Test Source Folder
  • I am importing the latest version of JUnit
  • All annotations are being imported properly except the @Test annotation

Due to the test annotation not being imported properly I face a "Cannot resolve symbol 'Test'" error when hovering over the @Test annotation in my CalculatorTest.class.

What I've tried so far:

  • Using plenty of different JUnit versions (from 4.0 to 5.8)
  • Checking whether the JUnit Plugin has been enabled (it is enabled)
  • Invalidating the cache and restarting IntelliJ
  • Updating IntelliJ to the latest version and restarting my PC
  • Reimporting all dependencies

In Eclipse everything worked right of the bat. I just needed to add JUnit as a maven dependency and everything got imported propery. In IntelliJ however I can't get the @Test annotation to work. Everything else is working though so I am not sure why I specifically face problems with the @Test annotation.

I really appreciate any help so thanks in advance!

Aucun commentaire:

Enregistrer un commentaire