⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basetestrunner.java

📁 junit中的软件设计模式 源代码,看了挺有收获的
💻 JAVA
字号:
package junit.textui;

import junit.framework.*;
import java.lang.reflect.*;
import java.text.NumberFormat;
import java.io.*;
import java.util.*;

/**
 * Base class for all test runners.
 * This class was born live on stage in Sardinia during XP2000.
 */
public abstract class BaseTestRunner{
	public static final String SUITE_METHODNAME= "suite";

    /**
     * Returns the Test corresponding to the given suite. This is
     * a template method, subclasses override runFailed(), clearStatus().
     */
    public Test getTest(String suiteClassName) {
        if (suiteClassName.length() <= 0) {
            return null;
        }
        Class testClass= null;
        try {
            testClass= Class.forName(suiteClassName);
        } catch(Exception e) {
            return null;
        }
        Method suiteMethod= null;
        try {
            suiteMethod= testClass.getMethod(SUITE_METHODNAME, new Class[0]);
         } catch(Exception e) {
             // try to extract a test suite automatically
            return new TestSuite(testClass);
        }
        Test test= null;
        try {
            test= (Test)suiteMethod.invoke(null, new Class[0]); // static method
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return test;
    }


}

⌨️ 快捷键说明

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