📄 basetestrunner.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 + -