Eclipse grails 作为 JUnit 测试运行

标签 eclipse testing grails junit

我是使用 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/

相关文章:

testing - CasperJS HTTP 身份验证

java - JUnit 可以用作 Spring 中浏览器测试的替代品吗?

caching - grails中springcache插件的使用

grails - Grails + Apache Shiro插件-设置 session 超时

eclipse - Eclipse 中的 `SDK` 包

java - JTextArea 不显示输出到它的每一行

java - 如何自动构建混合的 Scala\Java Eclipse 工作区?

ruby - rspec: 'should_receive' 具有多个参数预期

grails - Groovy域对象列表未保存且未在 Controller 中排序

java.lang.ClassCastException - 将 WAR 部署到 GlassFish 3.1.2。 - JNDI 查找可能无效?