Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 456
Nora Avatar asked Feb 12 '26 11:02

Nora


1 Answers

  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

like image 177
Maria Ines Parnisari Avatar answered Feb 15 '26 02:02

Maria Ines Parnisari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!