gpt4 book ai didi

Eclipse grails 作为 JUnit 测试运行

转载 作者:行者123 更新时间:2023-11-28 20:32:35 27 4
gpt4 key购买 nike

我是使用 Eclipse for Grails(使用 STS)的新手,我正在尝试找出一种运行单元测试的简单方法。我发现我可以通过右键单击 Run As > Grails Command (test-app) 来完成。这有效但速度很慢,测试输出转到测试报告 html 页面并且没有明显的可点击堆栈跟踪。

我还可以执行 Run As > JUnit Test,这看起来要快得多,并为我提供了在非 Grails 测试中可用的传统 JUnit 控制台。运行单元测试时,两者有区别吗? grails 命令是在设置其他东西还是在做其他事情?

最佳答案

您正在执行一个全面的测试,所有的花里胡哨都打开了。 :)

根据文档:

test-app: Runs all Grails unit and integration tests and generates reports.

为集成测试设置容器使其更“昂贵”。

您可以通过使用“unit:”作为参数来限制正在运行的测试用例,以指示只需要运行单元测试。 (当不直接从 eclipse 使用 JUnit 时)

在你的情况下你可以这样做:

test-app unit:

或针对特定的 FooBarTests.groovy 文件:

test-app unit: FooBar

您可以选择添加 -echoOut 或 -echoErr 以获得更详细的输出。

Check out the docs for more info and different phases of testing.

关于Eclipse grails 作为 JUnit 测试运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12788755/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com