Search code examples
javamavenintellij-ideajunitjunit-jupiter

IDE does not recognize Assumptions


I am using Junit5, and my IDE (IntelijIdea) is not recognize Assumptions. I am actually do not know why, but may be there is some dependecy on Maven I do not connect into project. Below I will show you the sample of my code.

This is my Assumptions import.

import org.junit.jupiter.api.Assumptions;

And this is wrong code (I can not compile it, compiler does not know what is assumeTrue() )

@Test
@EnabledOnOs(OS.MAC)
void testInsertion() {
    assumeTrue(isServerUp); //That place is crashing
    assertThrows(NullPointerException.class, () -> Connection.insertTheInstance(person),
            "");

If you are familiar with this case then, please, share you knowledge) Many thanks!


Solution

  • It's a import problem probably. Try:

      <dependency>
         <groupId>org.junit.jupiter</groupId>
         <artifactId>junit-jupiter-api</artifactId>
         <version>5.6.2</version>
         <scope>test</scope>
      </dependency> 
    
    • Check if maven import is ok
    • Close your project in intellij
    • Delete your .m2 folder in your HOME directory (user/yourusername in windows, /home in linux)
    • Execute in a terminal in your project: mvn dependency:purge-local-repository clean.
    • Open your project again

    If it's not ok yet, try the junit 4.12. Its have Assumptions too.