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() {
}

猜你喜欢

转载自www.cnblogs.com/vincenshen/p/10427839.html