JUnit4 入门笔记

Test注解的两个可选参数 expected timeout

The Test annotation supports two optional parameters.
  The first, expected, declares that a test method should throw an exception.
  If it doesn't throw an exception or if it throws a different exception than the one declared, the test fails.

@Test(expected = Exception.class)
	public void Test() {
}

The second optional parameter, timeout, causes a test to fail if it takes longer than a specified amount of clock time (measured in milliseconds).

@Test(timeout = 1000)
	public void Test() {
}
posted @ 2019-02-24 20:53  Vincen_shen  阅读(144)  评论(0编辑  收藏  举报