delayedtest.java

来自「《透视Java》的源码」· Java 代码 · 共 33 行

JAVA
33
字号
package covertjava.loadtest;

import junit.framework.*;
import junit.extensions.TestDecorator;

/**
 * <p>A test decorator that executes the given test after a specified delay</p>
 * <p>Copyright: Copyright (c) 2004 Sams Publishing</p>
 * @author Alex Kalinovsky
 * @version 1.0
 */
public class DelayedTest extends TestDecorator {
    protected int delay;

    /**
     * Executes the given test after the delay
     * @param test test to run
     * @param delay delay to sleep in milliseconds before running the test
     */
    public DelayedTest(Test test, int delay) {
        super(test);
    }

    public void run(TestResult result) {
        try {
            Thread.currentThread().sleep(delay*1000);
            super.run(result);
        }
        catch(InterruptedException x) {
        }
    }
}

⌨️ 快捷键说明

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