-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not import testng when scope is marked 'test' in maven pom.xml #1458
Comments
Hi, It looks you have a problem with maven or your IDE. Maybe you can share your project which will help us to reproduce the issue. |
You can check if maven download the testng jar success in the local maven repo: |
@juherr You can find a simple sample here: https://github.com/jedi-tester/test Basically everything seems to be working when running tests from console with maven. However I can not run tests from IDE because IntelliJ does not see testng classes. Only if I remove 'test' scope from testng dependency in pom.xml then everything seems to be working as expected |
This is more an issue with IntelliJ than TestNG. Same code works well with NetBeans / Eclipse. |
@elishaebenezer Thanks for the feedback! Do you reproduce the issue on intellij too? |
Same question on O: https://stackoverflow.com/questions/44756498/importing-testng-classes-when-scope-marked-test BTW, you should post an issue on IDEA bugtracker: https://youtrack.jetbrains.com/issues |
Try changing the scope as compile. |
@juherr This is a bit unrelated to this question, but I have few classes like dataproviders in 'src/main/java' and maven is explicitly throwing error for not being able to detect the testNG annotations for classes of 'src/main/java'. Can you tell me how to fix that? |
Hi, I understand that this issue posted in 2021 and I have read this since I faced the same issues. Hope you found the solution already. The reason in my case is in pom.xml for testng dependency was set to 'test'. The value 'test' limits the dependency to use it under src/test/java/. If I remove the or set it to 'compile' then I am able to import testng classes under src/main/java. Maven explains about dependency and scope here https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
<scope>test</scope>
</dependency> Hope this helps someone! Cheers!! |
TestNG Version
6.11
Expected behavior
Actual behavior
I've marked testng dependency scope as 'test'
Trying to import testng annotations from test folder, however
import org.testng.annotations.Test;
gets marked as error - Can not resolve symbol 'Test'Is the issue reproductible on runner?
Test case sample
testng dependency in pom.xml
folders layout:
The text was updated successfully, but these errors were encountered: