简体   繁体   English

Junit测试套件,无需创建空类

[英]Junit Test suite without creating empty class

I have tree test classes 我有树测试班

class Test1 {........ //some tests ... } 
class Test2 {..... //Some Tests.... } 
class Test3 {....//Some tests.... }

and to create test suite i created 并创建我创建的测试套件

@RunWith(Suite.class)
@Suite.SuiteClasses({Test1.class,
        Test2.class,
        Test3.class})
public class MyTestSuite { 
}

now this test suite is empty. 现在该测试套件为空。

Is there way we do NOT create empty class and directly give Test1 , Test2 and Test3 class annotation that its is a part of MyTestSuite class ? 有没有办法我们不创建空类,而直接给它是MyTestSuite类的一部分的Test1,Test2和Test3类批注?

No you cannot. 你不能。 Class is needed, otherwise how your compiler know what to compile. 需要类,否则您的编译器如何知道要编译的内容。 In java the syntax of enum or class must exist in the java file or you will not able to run the program. 在Java中,java文件中必须存在enum或class的语法,否则您将无法运行该程序。 The empty class for the test suite is just a holder for the program to compile. 测试套件的空类只是要编译的程序的持有人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM