【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 测试技术 Maven
Junit单元测试 @Test的使用教程
这篇文章是一个关于Junit单元测试中`@Test`注解使用的教程,包括在Maven项目中添加Junit依赖、编写带有@Test注解的测试方法,以及解决@Test注解不生效的常见问题。
|
Java 测试技术
java的Junit测试@Test@Before@After Assert.assertEquals
java的Junit测试@Test@Before@After Assert.assertEquals
101 0
Junit4.12报错:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
Junit4.12报错:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
Junit报错java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=test]的解决
Junit报错java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=test]的解决
200 0
导入了Junit依赖,但@Test注解依然爆红~
导入了Junit依赖,但@Test注解依然爆红~
457 0
|
IDE Java Maven
java: 程序包org.junit不存在,无法通过Test测试
IDEA Error: java: 程序包org.junit不存在,无法通过Test测试
3441 0
java: 程序包org.junit不存在,无法通过Test测试
|
Java Spring
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
311 0
第四篇:SpringBoot如何整合Junit -- @SpringBootTest + @Test
|
Java 测试技术 数据库
Junit - 优先级测试(FixMethodOrder Test)
Junit - 优先级测试(FixMethodOrder Test)
465 0
Junit - 优先级测试(FixMethodOrder Test)
|
XML Java 测试技术
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
这篇文章介绍了Spring5框架的三个新特性:支持@Nullable注解以明确方法返回、参数和属性值可以为空;引入函数式风格的GenericApplicationContext进行对象注册和管理;以及如何整合JUnit5进行单元测试,同时讨论了JUnit4与JUnit5的整合方法,并提出了关于配置文件加载的疑问。
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
|
7月前
|
Java 测试技术 Android开发
课时148:junit测试工具
课时148介绍了JUnit测试工具的使用,包括定义、配置和编写测试程序。JUnit是流行的用例测试工具,用于确保代码稳定性。
105 0