定义一个类,在类的上方添加@RunWith(Suite.class)和@SuiteClasses({XX.class,YY.class,...}) 实例有两个类分别为:public class Login{ @Beforepublic void setUp() throws Exception{......} @Testpublic void test(){......} @Afterpublic void tearDown() throws Exception{......}}
public class Logout{@Beforepublic void setUp() throws Exception{......} @Testpublic void test(){......} @Afterpublic void tearDown() throws Exception{......}}
想要同时运行这两个Junit测试用例,则可以如下@RunWith(Suite.class)@SuiteClasses({ Login.class,//登录 Logout.class//登出})public class Control{ @test public void execute(){//内容可以为空。}}
时间: 2024-12-09 02:59:32