【JUnit】@Test 报错,"Test cannot be resolved to a type"

简介: 想用单元测试 JUnit 单元测试下写好的方法,发现写 @Test 标签报错了,"Test cannot be resolved to a type" 原来是项目没有导入 JUnit 库,解决办法很简单 项目右键 -> Build Path -> Configure Build Path -> Libraries -> Add Library -> JUnit -> next -> finish OK,问题解决了。

想用单元测试 JUnit 单元测试下写好的方法,发现写 @Test 标签报错了,"Test cannot be resolved to a type" 原来是项目没有导入 JUnit 库,解决办法很简单 项目右键 -> Build Path -> Configure Build Path -> Libraries -> Add Library -> JUnit -> next -> finish OK,问题解决了。 记录下免得下次给忘了。

目录
相关文章
|
Java 测试技术 Android开发
Junit - 期望异常测试(Expected Test)
Junit - 期望异常测试(Expected Test)
828 0
|
4月前
|
Java
Junit4.12报错:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
Junit4.12报错:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
|
4月前
Junit报错java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=test]的解决
Junit报错java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=test]的解决
36 0
|
6月前
导入了Junit依赖,但@Test注解依然爆红~
导入了Junit依赖,但@Test注解依然爆红~
|
IDE Java Maven
java: 程序包org.junit不存在,无法通过Test测试
IDEA Error: java: 程序包org.junit不存在,无法通过Test测试
2359 0
java: 程序包org.junit不存在,无法通过Test测试
|
Java Spring
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
167 0
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
|
Java 测试技术 数据库
Junit - 优先级测试(FixMethodOrder Test)
Junit - 优先级测试(FixMethodOrder Test)
299 0
Junit - 优先级测试(FixMethodOrder Test)
|
测试技术 Android开发
Junit - 超时测试(Timeout Test)
Junit - 超时测试(Timeout Test)
278 0
Junit - 超时测试(Timeout Test)
|
测试技术 Android开发
Junit - 忽略测试(Ignore Test)
Junit - 忽略测试(Ignore Test)
467 0
Junit - 忽略测试(Ignore Test)
|
测试技术 Android开发
Junit - 套件测试(Suite Test)
Junit - 套件测试(Suite Test)
145 0
Junit - 套件测试(Suite Test)