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



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 


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 ? 




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:


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




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.


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


Please sign in to leave a comment.