chrono.java

来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 29 行

JAVA
29
字号
package org.uispec4j.utils;

import junit.framework.Assert;

import java.util.Date;

public class Chrono {
  private Date startDate;

  public static Chrono start() {
    return new Chrono();
  }

  private Chrono() {
    startDate = new Date();
  }

  public void assertElapsedTimeLessThan(long max) {
    long elapsed = getElapsedTime();
    Assert.assertTrue("Maximum elapsed time reached: " + elapsed + " >= " + max,
                      elapsed < max);
  }

  public long getElapsedTime() {
    Date currentDate = new Date();
    return currentDate.getTime() - startDate.getTime();
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?