定向班第二期_单元测试框架_1016

课前准备

用例分组执行


    @Category({SlowGroup.class, FastGroup.class})
    @Test
    public void testDemo1(){
        assertTrue(false);
    }



import org.junit.experimental.categories.Categories;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Categories.class)
@Categories.IncludeCategory(SlowGroup.class)
@Categories.ExcludeCategory(FastGroup.class)
@Suite.SuiteClasses({
        TestGroups.class
})

public class TestGroupsSuite {
}

断言体系

    @Test
    public void testDemo3(){
        assertThat("actual value close to 10",
                9.88,
                anyOf(closeTo(10.0, 0.1), equalTo(9.88) ));
    }

JUnit4数据驱动

JUnit5数据驱动

Maven执行

Allure2

Mock

关闭