Nora
Nora

Reputation: 1893

TestNG-functionality not recognized by Intellij

I am trying to use TestNG to test my Java-code. The TestNG-plugin is installed in IntelliJ, and the dependency:

<dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
</dependency>

has been added to Maven. However, when I write "@Test" in a class, IntelliJ gives the error-message: "can not resolve symbol 'Test'.

Importing org.testng.annotations.Test is not recognized either. It just seems like Intellij is ignoring the Maven-dependency.

Here is the project structure and the error:

enter image description here

Should I have done something more with TestNG, rather then just adding the Maven dependency?

Upvotes: 3

Views: 12235

Answers (1)

Maria Ines Parnisari
Maria Ines Parnisari

Reputation: 17486

  1. Run mvn clean

  2. Set the scope of testng to test, i.e.:

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.12</version>
        <scope>test</scope>
    </dependency>
    
  3. Run mvn install

Upvotes: 3

Related Questions