Unit testing 如何对groovy测试进行分组?

Unit testing 如何对groovy测试进行分组?,unit-testing,groovy,junit,Unit Testing,Groovy,Junit,我有一些groovy测试用例(即扩展GroovyTestCase(版本1.8.2))的类。比如说 class TestCaseA extends GroovyTestCase {void testA1() {...} void testA2() {...}} class TestCaseB extends GroovyTestCase {void testB1() {...} void testB2() {...}} 类TestCaseA扩展了GroovyTestCase{void testA1

我有一些groovy测试用例(即扩展
GroovyTestCase
(版本1.8.2))的类。比如说

class TestCaseA extends GroovyTestCase {void testA1() {...} void testA2() {...}} class TestCaseB extends GroovyTestCase {void testB1() {...} void testB2() {...}} 类TestCaseA扩展了GroovyTestCase{void testA1(){…}void testA2(){…} 类TestCaseB扩展了GroovyTestCase{void testB1(){…}void testB2(){…} 我想对测试进行分组(测试方法)。
比如说,

group X: TestCaseA.testA1, TestCaseB.testB1, TestCaseB.testB2, group Y: TestCaseB.testB2 group Z: TestCaseA.testA1, TestCaseA.testA2 X组:TestCaseA.testA1、TestCaseB.testB1、TestCaseB.testB2、, Y组:TestCaseB.testB2 Z组:TestCaseA.testA1、TestCaseA.testA2 为了实现这样的分组,我想添加注释。(我可以更改测试源)。
例如:

class TestCaseA extends GroovyTestCase { @TestGroup (TestGroup.X, TestGroup.Z) void testA1() {...} @TestGroup (TestGroup.Z) void testA2() {...} } 类TestCaseA扩展了GroovyTestCase{ @TestGroup(TestGroup.X、TestGroup.Z) void testA1(){…} @TestGroup(TestGroup.Z) void testA2(){…} } 现在,我想编写一个自定义的JUnit Runner,它接收“测试组”(例如,作为命令行参数或环境变量),并只运行用这些组注释的测试方法


这有意义吗?有哪些替代方案?如何实现自定义JUnit Runner

可能不是您想要的,但另一种选择是使用TestNG,它支持开箱即用的组概念。应该可以与Groovy配合使用:


我知道这对你没用,如果你被JUnit困住了…

我同意。这应该行得通。我最近一直在玩这个东西,我知道它会有用的。