Eclipse grails作为JUnit测试运行

时间:2012-10-08 20:11:09

标签: eclipse testing grails junit

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

我也可以做Run As > JUnit Test,这看起来要快得多,并且给我提供了非Grails测试中可用的传统JUnit控制台。运行单元测试时,两者有区别吗? grails命令是否设置其他内容或执行其他操作?

1 个答案:

答案 0 :(得分:2)

你正在进行全面的测试,所有的花里胡哨。 :)

根据文件:

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.