微信登录

测试 - Text - junit-4.xx.x.jar

安装

https://junit.org/junit4/
Download and install
跳到github
练习用 - junit.jar - 下载jar

编译器引入就看Eclipse、IDEA、引入

例子

expect后面接异常类
timtout后面接时间, 符合则为ture

  1. import org.junit.Text
  2. public class xxx{
  3. @Text
  4. public void xxx(){}
  5. @Test (expected = NullPointException)
  6. public void testNull() {
  7. String s = null;
  8. s.length();
  9. }
  10. @Test (timeOut = 1000)
  11. public void testTimeOut() {
  12. while(true) {
  13. }
  14. }
  15. }