Class<?> clazz = description.getTestClass(); String mname = description.getMethodName(); Collection<Annotation> annotations = description.getAnnotations(); final int rounds = getRoundsForFullMethodName(clazz.getCanonicalName() + "." + mname);
Class<?> clazz = description.getTestClass(); String mname = description.getMethodName(); Collection<Annotation> annotations = description.getAnnotations(); final int rounds = getRoundsForFullMethodName(clazz.getCanonicalName() + "." + mname);
@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; }
public class MyRunner extends BlockJUnit4ClassRunner { public MyRunner(Class<?> klass) throws InitializationError { super(klass); } @Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description= describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { if (description.getAnnotation(Deprecated.class) != null) { System.out.println("name=" + description.getMethodName() + " annotations=" + description.getAnnotations()); } runLeaf(methodBlock(method), description, notifier); } } }
/** * {@inheritDoc } */ @Override public Collection<Annotation> getAnnotations() { return d.getAnnotations(); }
public static Set<Annotation> getAnnotations(Description description) { Set<Annotation> annotations = new HashSet<Annotation>(); annotations.addAll(description.getAnnotations()); annotations.addAll(Arrays.asList(description.getTestClass().getAnnotations())); return annotations; } }
public static final Description convertDescription(URL repoURL, String featureName, String featureVersion,Description description) { String delegateDisplayName = description.getDisplayName(); delegateDisplayName = delegateDisplayName + "[repoUrl: " + repoURL+ ", Feature: " + featureName + " " +featureVersion + "]"; Collection<Annotation> annotations = description.getAnnotations(); Annotation[] annotationArray = annotations.toArray(new Annotation[annotations.size()]); Description newDescription = Description.createSuiteDescription(delegateDisplayName,annotationArray); return newDescription; } }
@Override public void evaluate() throws Throwable { try { // Execute handlers before statement execution before(description.getAnnotations()); // Execute statements base.evaluate(); } finally { // Execute handlers after statement execution after(description.getAnnotations()); } } };
@Override public void evaluate() throws Throwable { try { // Execute handlers before statement execution before(description.getAnnotations()); // Execute statements base.evaluate(); } finally { // Execute handlers after statement execution after(description.getAnnotations()); } } };
@Override public void evaluate() throws Throwable { List<Annotation> annotations = new ArrayList<Annotation>(); annotations.addAll(description.getAnnotations()); annotations.addAll(Arrays.asList(description.getTestClass().getAnnotations())); interceptor.intercept(description.getMethodName(), action, annotations, clients, environmentProperties); base.evaluate(); } };
@Override protected Description describeChild(FeaturesRunner child) { Description description = child.getDescription(); return Description.createTestDescription(description.getTestClass(), description.getDisplayName() + " " + Arrays.toString(runnersParams.get(child)), description.getAnnotations().toArray(new Annotation[0])); }
static void dumpTest(StopWatchRunListener myListener, Description description, String offset) { System.out.println(offset + "T -----"); System.out.println(offset + "T display name=" + description.getDisplayName()); System.out.println(offset + "T getClassName=" + description.getClassName()); System.out.println(offset + "T getMethodName=" + description.getMethodName()); System.out.println(offset + "T test count=" + description.testCount()); System.out.println(offset + "T getAnnotations=" + description.getAnnotations()); System.out.println(offset + "T runtime =" + myListener.getRunTime(description)); }
private Description createDescription(Class<?> testClass, String displayName, Description orig) { Serializable uniqueId = getUniqueIdFromDescription(orig); Annotation[] annotations = orig.getAnnotations().toArray( new Annotation[0]); Description desc; try { desc = descConstr.newInstance(testClass, displayName, uniqueId, annotations); } catch (Throwable t) { throw new RuntimeException(t); } for (Description child : orig.getChildren()) { desc.addChild(rewriteIndirectChildDescription(child)); } originalToRewrittenDescriptionMap.put(orig, desc); return desc; }
@Override protected void starting(Description d) { this.magnoliaConfigurationProperties = mock(MagnoliaConfigurationProperties.class); for (final Annotation annotation : d.getAnnotations()) { handleAnnotation(annotation); } }
@Override public Statement apply(Statement base, Description description) { Statement result = base; try { //Check if Requires is used directly. checkConstraint(description.getAnnotation(Requires.class), null); for (Annotation annotation : description.getAnnotations()) { //Check if Requires is annotating an other annotation checkConstraint(annotation.annotationType().getAnnotation(Requires.class), annotation); } } catch (UnsatisfiedRequirementException e) { log.log(Level.WARNING, String.format("Unsatisfied assumption in test class %s. Requirement problem: %s.", description.getTestClass().getName(), e.getMessage())); return new UnsatisfiedRequirement(e.getMessage()); } return result; } }
@Override protected Description describeChild(FrameworkMethod method) { final Description s = super.describeChild(method); return Description.createTestDescription(s.getClassName(), s.getMethodName() + paramsToString(params), s.getAnnotations().toArray(new Annotation[0])); }
@Override public void run(final RunNotifier notifier) { if (desc == null) { desc = getDescription(); } notifier.fireTestRunStarted(desc); for (Description mod : desc.getChildren()) { if (mod.getAnnotations().stream().anyMatch(t -> t instanceof CompilationFailed)) { notifier.fireTestFailure(new Failure(desc, new IllegalArgumentException(mod.getDisplayName() + " had importing errors"))); continue; } Listener listener = new Listener(notifier, mod); TestEvaluator runner = new TestEvaluator(evaluator, listener); } notifier.fireTestRunFinished(new Result()); }
@Override public void testStarted(Description description) throws IllegalAccessException { if (description.isTest()) { String methodName = extractMethodName(description); TestCaseStartedEvent event = new TestCaseStartedEvent(getSuiteUid(description), methodName); event.setTitle(methodName); Collection<Annotation> annotations = new ArrayList<>(); for (Annotation annotation : description.getAnnotations()) { annotations.add(annotation); } AnnotationManager am = new AnnotationManager(annotations); am.update(event); getLifecycle().fire(event); } }
@Test public void issue213ShouldNotInitAnnotationsArrayWithNull() throws InitializationError { final MetamorphTestRunner runner = new MetamorphTestRunner(Dummy.class, "/org/metafacture/metamorph/test/test-case-runner-test-dummy.xml"); final MetamorphTestCase metamorphTestCase = runner.getChildren().get(0); final Description description = runner.describeChild(metamorphTestCase); assertNotNull(description.getAnnotations()); }
public void startFakeTestCase(Description description) throws IllegalAccessException { String uid = getSuiteUid(description); String name = description.isTest() ? description.getMethodName() : description.getClassName(); TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name); event.setTitle(name); AnnotationManager am = new AnnotationManager(description.getAnnotations()); am.update(event); getLifecycle().fire(event); }