當前位置: 首頁>>代碼示例>>Java>>正文


Java Description.getAnnotations方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:RunAsFullyAuthenticatedRule.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:12,代碼來源:AllureMarathonRunListener.java

示例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;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:16,代碼來源:CategoryWithParameterizedRunnerFactoryTest.java

示例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;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:48,代碼來源:LoadTestRule.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:13,代碼來源:AllureMarathonRunListener.java


注:本文中的org.junit.runner.Description.getAnnotations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。