当前位置: 代码迷 >> 综合 >> 找不到 org.testng.annotations.Test
  详细解决方案

找不到 org.testng.annotations.Test

热度:40   发布时间:2023-10-15 22:09:18.0
注解@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

  相关解决方案