本文主要是介绍【单元测试】使用Gradle运行@SpringBootTest单元测试提示“No tests found for given includes。。。 “解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题:
在IntelliJ IDEA中运行Gradle服务的单元测试时报错
错误提示:
Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:test’.
No tests found for given includes: [DemoTest.queryString](filter.includeTestsMatching)
单元测试代码如下:
@SpringBootTest
class DemoTest{@Autowiredlateinit var redisTemplate: RedisTemplate<String, String>@Testfun queryString() {val result = redisTemplate.opsForHash<String, String>().get("mykey", "1")println(result)}
}
依赖如下:
testImplementation("org.springframework.boot:spring-boot-starter-test:2.3.2.RELEASE")
gradle设置如下:
tasks.withType<Test> {enabled = true
}
解决办法:
按以下步骤设置:
- 点击File > Setting (Ctrl+Alt+S)
- 找到Build, Execution, Deployment > Build Tools > gradle
- 将Run Tests using改为Intellij IDEA
当前文章作为问题记录,方便日后查询
这篇关于【单元测试】使用Gradle运行@SpringBootTest单元测试提示“No tests found for given includes。。。 “解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!