本文整理匯總了Java中org.junit.runner.Description.getTestClass方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.getTestClass方法的具體用法?Java Description.getTestClass怎麽用?Java Description.getTestClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.runner.Description
的用法示例。
在下文中一共展示了Description.getTestClass方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import org.junit.runner.Description; //導入方法依賴的package包/類
public Statement apply(final Statement base, Description description) {
Class<?> testClass = description.getTestClass();
init(description.getMethodName(), testClass.getSimpleName());
suppressCleanupErrors = testClass.getAnnotation(LeaksFileHandles.class) != null
|| description.getAnnotation(LeaksFileHandles.class) != null;
return new TestDirectoryCleaningStatement(base, description.getDisplayName());
}
示例2: resolveOptions
import org.junit.runner.Description; //導入方法依賴的package包/類
private BenchmarkOptions resolveOptions(Description description) {
// Method-level
BenchmarkOptions options = description.getAnnotation(BenchmarkOptions.class);
if (options != null) return options;
// Class-level
Class<?> clz = description.getTestClass();
while (clz != null)
{
options = clz.getAnnotation(BenchmarkOptions.class);
if (options != null) return options;
clz = clz.getSuperclass();
}
// Defaults.
try
{
return getClass()
.getDeclaredMethod("defaultOptions")
.getAnnotation(BenchmarkOptions.class);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
示例3: starting
import org.junit.runner.Description; //導入方法依賴的package包/類
/**
* sets test class and method name to build path to file
*
* @param description description of the current test method
*/
@Override
protected void starting(Description description) {
this.testClass = description.getTestClass();
this.methodName = description.getMethodName();
}
示例4: testStarted
import org.junit.runner.Description; //導入方法依賴的package包/類
/**
*
* @see org.junit.runner.notification.RunListener#testStarted(org.junit.runner.Description)
*/
@Override
public void testStarted( Description description ) throws Exception {
if (log.isDebugEnabled()) {
log.debug("testStarted(): Called when an atomic test is about to be started. Description generally class and method: "
+ description); //, new Exception( "debugging trace" ) );
}
lastStartedMethodIsFailing = false;
Class<?> testClass = description.getTestClass(); //testResult.getTestClass().getRealClass();
String suiteName;
String suiteSimpleName;
String tcName = getTestName(description);
// Update last started method. Note that testStarted() is invoked even before @Before methods
lastStartedMethod = description.getMethodName(); // TODO: check for overridden methods
String tcDescription = getTestDescription(description);
suiteName = testClass.getName(); // assuming not JUnit 3 class "TestSuite"
suiteSimpleName = testClass.getSimpleName();
// check if we need to start a new group
if (!suiteName.equals(lastSuiteName)) {
if (lastSuiteName != null) {
logger.endSuite();
}
String packName = suiteName.substring(0, suiteName.lastIndexOf('.'));
logger.startSuite(packName, suiteSimpleName);
lastSuiteName = suiteName;
}
// start a scenario and test case
logger.startTestcase(suiteName, suiteSimpleName, tcName, "", tcDescription);
// send TestStart event to all ATS agents
TestcaseStateEventsDispacher.getInstance().onTestStart();
logger.info("[JUnit]: Starting " + suiteName + "@" + tcName);
super.testStarted(description);
}
示例5: extractNameFromDescription
import org.junit.runner.Description; //導入方法依賴的package包/類
private String extractNameFromDescription(final Description description) {
return description.getTestClass() == null ? description.getClassName() : description.getTestClass()
.getSimpleName();
}
示例6: testStarted
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public void testStarted(final Description description) throws Exception {
if (!Objects.equals(lastClassName, description.getTestClass())) {
lastClassName = description.getTestClass();
lastMethodName = null;
println("\n");
println(simplifyClassName(lastClassName) + "\n");
}
}