注解@Test找不到 org.testng.annotations.Test

找不到 org.testng.annotations.Test

非常明确依赖包已经导入,看到相关解释 https://segmentfault.com/q/1010000009108958

将<scope>test</scope>去掉,就可以看见了。

找不到 org.testng.annotations.Test

找不到 org.testng.annotations.Test

本来到这里就结束了,我又再次查看了刚刚那篇文章。 

找不到 org.testng.annotations.Test

这个回答太棒了,我再次把scope加上,果然在test类中,是可以找到这个包的,在Java包中还是找不到的(红色波浪找不到包)。

重要的句子再抄写一遍,

maven在编译src/main/java的时候,是不引用<scope>test</scope>的jar;

maven在编译src/test/java的时候,引用<scope>test</scope>。

(这时候如果pom中引用了junit包,会容易导成这个包 import org.junit.Test;)

测试的类就放在测试类的位置比较好。

找不到 org.testng.annotations.Test

相关文章:

  • 2021-09-30
  • 2021-04-23
  • 2021-10-10
  • 2021-05-07
  • 2021-10-13
  • 2021-11-22
  • 2021-06-17
  • 2022-03-01
猜你喜欢
  • 2021-11-19
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-09-03
  • 2021-09-29
相关资源
相似解决方案