在Eclipse中将项目转换为Gradle后无法运行JUnit测试用例 [英] Unable to run JUnit test cases after converting project to Gradle in Eclipse
问题描述
我当时使用Maven在Eclipse中管理我的项目,但认为Gradle看起来可以使我受益匪浅.我正在尝试实现CI/CD管道,但想检查某些事情(例如单元测试成功和代码覆盖率).使用
I was using Maven to manage my project in Eclipse, but decided that Gradle looked like something that could end up benefiting me more. I'm trying to implement a CI/CD pipeline, but want to check certain thing (unit test success, and code coverage for example). After converting my project using
gradle eclipse
我发现我不再能够通过上下文菜单运行JUnit测试用例
I find that I am no longer able to run JUnit test cases via the context menu
Right Click -> Run As... -> JUnit Test
出现以下错误
Class not found <package>.<class>
但是当我跑步时
gradle test
所有这些都通过了,但是不给我更多信息(哪些正在运行,哪些失败,哪些错误).
All of them pass, but don't give me any more information (which were run, which ones failed, which ones errored out).
通过切换到Gradle项目,是否所有任务现在都只能在Gradle的上下文中运行? Eclipse中未报告任何错误,并且构建正常.我已验证文件位于预期位置.
By switching to a Gradle project, can all tasks only be run in the context of Gradle now? There are no errors reported in Eclipse, and building works fine. I have verified that the files are in the expected locations.
推荐答案
我能够按照以下步骤解决此问题.
I was able to solve this doing the following steps.
- 在eclipse中关闭项目
- 从Eclipse工作区(而不是文件系统)中删除项目
- 日食
- 打开命令行终端
- 运行
gradle cleanEclipse eclipse
- 日食
- 作为gradle项目导入
- Close the project in eclipse
- Delete the project from the eclipse workspace (not from the file system)
- Close eclipse
- Open command line terminal
- Run
gradle cleanEclipse eclipse
- Open eclipse
- Import as a gradle project
到那时,一切都重新设置了.
At that point, everything was set up again.
这篇关于在Eclipse中将项目转换为Gradle后无法运行JUnit测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!