标签:style blog color io 使用 java ar for 数据
| assertArrayEquals(expecteds, actuals) | 查看两个数组是否相等。 |
| assertEquals(expected, actual) | 查看两个对象是否相等。类似于字符串比较使用的equals()方法 |
| assertNotEquals(first, second) | 查看两个对象是否不相等。 |
| assertNull(object) | 查看对象是否为空。 |
| assertNotNull(object) | 查看对象是否不为空。 |
| assertSame(expected, actual) | 查看两个对象的引用是否相等。类似于使用“==”比较两个对象 |
| assertNotSame(unexpected, actual) | 查看两个对象的引用是否不相等。类似于使用“!=”比较两个对象 |
| assertTrue(condition) | 查看运行结果是否为true。 |
| assertFalse(condition) | 查看运行结果是否为false。 |
| assertThat(actual, matcher) | 查看实际值是否满足指定的条件 |
| fail() | 让测试失败 |
| @Before | 初始化方法,没个测试方法执行前都会执行 |
| @After | 释放资源,每个测试方法执行后都会执行 |
| @Test | 测试方法,在这里可以测试期望异常和超时时间 |
| @Ignore | 忽略的测试方法 |
| @BeforeClass | 针对所有测试,只执行一次,且必须为static void |
| @AfterClass | 针对所有测试,只执行一次,且必须为static void |
| @RunWith | 指定测试类使用某个运行器 |
| @Parameters | 指定测试类的测试数据集合 |
| @Rule | 允许灵活添加或重新定义测试类中的每个测试方法的行为 |
| @FixMethodOrder | 指定测试方法的执行顺序 |
@RunWith(Suite.class) @Suite.SuiteClasses({ AssertTests.class, FibonacciTest.class, JDemoTest.class }) public class AllCaseTest { }
@Rule public ExpectedException thrown = ExpectedException.none(); @Test public void shouldTestExceptionMessage() throws IndexOutOfBoundsException { List<Object> list = new ArrayList<Object>(); thrown.expect(IndexOutOfBoundsException.class); thrown.expectMessage("Index: 0, Size: 0"); list.get(0); Assert.assertEquals(1, list.get(0)); }
标签:style blog color io 使用 java ar for 数据
原文地址:http://www.cnblogs.com/phenixyu/p/3969064.html