本文整理匯總了Java中org.junit.runner.Description.getAnnotations方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.getAnnotations方法的具體用法?Java Description.getAnnotations怎麽用?Java Description.getAnnotations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.runner.Description
的用法示例。
在下文中一共展示了Description.getAnnotations方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMethodAnnotatedUserName
import org.junit.runner.Description; //導入方法依賴的package包/類
/**
*
* @param description the description object from JUnit
* @return the username specified in the {@link RunAsUser} annotation, if there was one, else <code>null</code>.
*/
private String getMethodAnnotatedUserName(Description description) throws IllegalArgumentException,
SecurityException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException
{
String result = null;
Collection<Annotation> annotations = description.getAnnotations();
for (Annotation anno : annotations)
{
if (anno.annotationType().equals(RunAsUser.class))
{
result = (String) anno.annotationType().getMethod("userName").invoke(anno);
}
}
return result;
}
示例2: startFakeTestCase
import org.junit.runner.Description; //導入方法依賴的package包/類
public void startFakeTestCase(Description description) {
String uid = getSuiteUid(description);
String name = description.isTest() ? getTestName() : getSuiteName(description);
TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
AnnotationManager am = new AnnotationManager(description.getAnnotations());
am.update(event);
fireClearStepStorage();
getLifecycle().fire(event);
}
示例3: shouldRun
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public boolean shouldRun(Description description) {
if (description.getChildren().size() == 0) {
return true;
}
List<Annotation> runnerAnnotations = new ArrayList<>();
Collections.addAll(runnerAnnotations, runner.getRunnerAnnotations());
for (Annotation a : description.getAnnotations()) {
if (runnerAnnotations.contains(a)) {
return true;
}
}
return false;
}
示例4: apply
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override public Statement apply(final Statement base, final Description description)
{
boolean loadTestingRequestedForThisMethod = false;
Collection<Annotation> annotations = description.getAnnotations();
for (Annotation anno : annotations)
{
if (anno.annotationType().equals(LoadTest.class))
{
loadTestingRequestedForThisMethod = true;
}
}
if (loadTestingRequestedForThisMethod)
{
log.debug(LoadTest.class.getSimpleName() + "-based testing configured for method " + description.getMethodName());
return new Statement()
{
@Override public void evaluate() throws Throwable
{
int executionCount = getCount();
int currentIndex = 1;
final CountDownLatch latch = new CountDownLatch(executionCount);
for (String username: people.getUsernames())
{
log.debug("About to start " + description.getMethodName() + ". " + currentIndex + "/" + executionCount + " as " + username);
new Thread(new StatementEvaluatorRunnable(username, base, latch)).start();
currentIndex++;
}
latch.await();
verify();
}
};
}
else
{
log.debug(LoadTest.class.getSimpleName() + "-based testing NOT configured for this method.");
return base;
}
}
示例5: testSuiteStarted
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testSuiteStarted(Description description) {
String uid = generateSuiteUid(getSuiteName(description));
TestSuiteStartedEvent event = new TestSuiteStartedEvent(uid, getSuiteName(description));
AnnotationManager am = new AnnotationManager(description.getAnnotations());
am.update(event);
event.withLabels(AllureModelUtils.createTestFrameworkLabel("Marathon"));
getLifecycle().fire(event);
}