Why Intellij doesn't import the TestNG maven dependency automatically ?

Answered

Hi,

I opened a Maven project and import all the maven dependencies. 

Everything is fine , except for TestNG dependencies. 

I have this in my POM.xml 

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope>
</dependency>

But I see this in my codes

I can see the TestNG appears in the Maven dependencies list , with (test) at the end. Not sure what does it mean. 

 

Then I saw this options in my editor

When I click "Add library 'Maven: org.testng:testng:6.14.3' to classpath" , it solves my problem straightaway. 

I checked the list of my Maven dependencies, I see the "(test)" disappear now. 

 

My questions:

  1. Why Intellij doesn't add the dependencies automatically ?  It works automatically for other dependencies in the list (javax , mysql, etc), except for this TestNG dependency. Is there something special with this TestNG dependency ? 
  2. What does " Adding XXX to classpath" mean?  Does it mean adding to External Libraries list ? 
  3. Secondly , in the Maven dependencies list, what does (test)  and (provided) mean ? 

Thanks. 

 

3 comments
Comment actions Permalink

Hello Jimmy,

I couldn't reproduce the issue with new sample maven project. Is it possible to provide your project for investigation? Looks like dependency was added with test scope:

<scope>test</scope>

and you try to import it in file under "sources" root instead of "test sources" root.

 

 

0
Comment actions Permalink

I am also experiencing this same problem, but with junit:junit marked in the pom.xml as test scope. I've noticed this seems to be an intermittent problem with IntelliJ.

0
Comment actions Permalink

I also came across this issue. Able to resolve by  adding the library to the classpath

0

Please sign in to leave a comment.