在 eclipse 2018-12 中使用 junit 4 或 5 测试 Grails 3.3.8 应用程序,可能吗?

发布于 2025-01-19 15:18:45 字数 482 浏览 3 评论 0原文

我正在开发一个 grails 项目,我想向它添加测试。 我使用了 spock 和 Geb,但我更喜欢 JUnit,但它不起作用。

我使用 eclipse 向导创建一个新的 Groovy 测试,我选择 junit4 或 junit 5 然后它创建一个新的测试类,

我右键单击并选择运行方式>联合测试 它应该显示 junit 视图,测试失败,但没有 我收到很多“默认导入 java.util/net/io 的包绑定无效” 和“无法检索超类”,“AbortCompilation ... AssertionError 无法解析。它是从所需的 .class 文件间接引用的” 来自 org.eclispe.jdt.core

,我从 org.eclispe.jdt.junit 得到一个由 NPE 引起的 invokingTargetException ,

这些是我多次尝试中的最后一个错误,我觉得这是不可能做到的。

如果有人设法让它发挥作用,请告诉你你是如何做到

i m working on a grails project and i want to add tests to it.
I used spock and Geb but i prefer JUnit but it doesnt work.

i m creating a new Groovy Test with the eclipse wizard, i select either junit4 or junit 5
then it creates a new test class

i right click and select run as> Junit Test
it should show the junit view with failing test but no
i get a lot of "Invalid package binding for default import java.util/net/io"
and a "could not retrieve superclass","AbortCompilation ... AssertionError cannot be resolved. it is indirectly referenced from required .class file"
from org.eclispe.jdt.core

and i get an invocationTargetException caused by a NPE from org.eclispe.jdt.junit

those are my last errors from my many attempts, i feel like it s just impossible to do it.

if someone managed to make it work, pls tell how you did it

regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温折酒 2025-01-26 15:18:45

在 eclipse 2018-12 中使用 junit 4 或 5 测试 Grails 3.3.8 应用程序,是吗?
可能吗?

是的。有很多方法可以做到这一点。

一种常见的方法是在 Eclipse 中创建一个启动配置,该配置将使用适当的参数执行 testintegrationTest Gradle 任务。

test Grails 3.3.8 app with junit 4 or 5 in eclipse 2018-12, is it
possible?

Yes, it is. There are numerous ways to do that.

A common way to do that is to create a launch config in Eclipse that will execute the test or integrationTest Gradle task with the appropriate parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文