Maven Compilation error [package org.testng.annotations does not exist]

后端 未结 9 1360
陌清茗
陌清茗 2020-12-10 11:09

I\'m pretty new to maven and I want to run my test classes using maven. I have generated the testng.xml and I have created the POM.xml file also. But when you run the

相关标签:
9条回答
  • 2020-12-10 11:56
    Beleive me below wil work replace "test" to "compile" in scope
    <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.9.13.6</version>
                <scope>compile</scope>
    </dependency>
    
    0 讨论(0)
  • 2020-12-10 11:57

    Set testng's scope to "provided" if you're building a web app and don't want it included in WEB-INF/lib.

    0 讨论(0)
  • 2020-12-10 12:00

    Even I had faced this issue and got a solution for the same.

    In your pom.xml file remove the scope and this should work fine.

    As per below code in pom.xml, remove the scope tag.

    Even though we have imported the maven dependency for Testng, when you add scope tag in XML file, it treats as JUnit annotation and not as Testng. So when I removed scope tag, My @Test Annotation was treated as Testng Annotation.

    <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.8.7</version>
                **<scope>test</scope>** //Remove this line and compile maven
    </dependency>
    
    0 讨论(0)
提交回复
热议问题