junit4

宿命java 2020-04-07

1、导包,导入到ClassPath中,不能导入到ModelPath中。

2、    @Test:测试方法    expected属性:抛出异常  timeout属性:设置超时

  @BeforeClass:所有方法运行前执行,static修饰

  @AfterClass:所有方法运行结束后执行,static修饰

  @Before:在每一个测试方法运行前执行

  @After:在每一个测试方法运行结束后执行

  @Ignore:忽略测试方法

  @RunWith:更改测试运行器

3、测试套件:组织测试类一起运行

1、测试套件类:空类

2、@RunWith(Suite.class)

   @Suite.SuiteClass({测试类1,测试类2...})

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({DemoTest.class,DemoTest2.class})
public class SuiteTest {

}

相关推荐

zhangdy0 / 0评论 2020-05-01