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

时间:2022-04-24
本文章向大家介绍Maven Compilation error [package org.testng.annotations does not exist],主要内容包括背景、解决办法、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

背景

在执行mvn test的时候,提示package org.testng.annotations does not exist

解决办法
  1. Open pom.xml file.
  2. Go to "Dependencies" tab.
  3. Select "testng" package and click on "Properties..."
  4. On opened screen change "Scope" option to "compile" and click "OK" to save it.
  5. Try to build your project again with "compile test" goals.

  • 将scope的test修改为compile