Home > Back-end >  Cannot resolve @org.unit.Test in IntelliJ Idea
Cannot resolve @org.unit.Test in IntelliJ Idea

Time:11-19

That's what pom.xml include:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
    </dependency>

That's actual test code:

import org.junit.Assert.*; // Cannot resolve symbol 'Assert'

public class CalculatorTest {

    @org.junit.Test // Cannot resolve symbol 'Test'
    public void add() {
        Assert.assertEquals(5.0, 5.0, 0.01); // Cannot resolve symbol 'Assert'
    }
}

Building Project just says that it cannot fine symbol 'Assert'. I tried Alt Enter -> Add 'JUnit4' to classpath but it only doubles the dependency in pop.xml.

CodePudding user response:

Try this (and it appears it worked as per OP's comment):

  1. File->Invalidate Caches
  2. check all boxes except Ask before downloading...
  3. Invalidate and Restart
  • Related