eclipse自带junit包,可右键直接新建junit类 静态引入:import static org.junit.Assert.* assert.*是类,静态引入会引入assert里的所有静态方法,可以不用写类名直接调用静态方法.非常多的assert方法. 运行结果:keep the bar green to keep the code clean. ---------------------- 实战的时候查一下Junit的API/hamcrest api 大部分asset方法都重载了一个可…
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 decla…