public JUnit4TestClass(Description test) { super(test.getTestClass()); } }
private static Description parentDescription(Description description) { Class<?> testClass= description.getTestClass(); return testClass == null ? null : Description.createSuiteDescription(testClass); }
public JUnit4SpockMethod(Description description) { super((Method)null); this.declaringClass = description.getTestClass(); this.description = description.getDisplayName(); }
private Description parentDescription(Description description) { Class<?> testClass = description.getTestClass(); if (testClass == null) { return null; } return Description.createSuiteDescription(testClass); }
private static boolean canHaveCategorizedChildren(Description description) { for (Description each : description.getChildren()) { if (each.getTestClass() == null) { return false; } } return true; } }
private void afterDistributedTest(Description testDescription) throws Throwable { System.out.println("\n\n[setup] END TEST " + testDescription.getTestClass().getSimpleName() + "." + testDescription.getMethodName()); int afterVmCount = getVMCount(); assertThat(afterVmCount).isEqualTo(beforeVmCount); }
@Override public Statement apply(Statement base, Description description) { if (description.isEmpty()) { return base; } else { final Class<?> testClass = description.getTestClass(); final FrameworkMethod frameworkMethod; try { final Method method = testClass.getMethod(description.getMethodName()); frameworkMethod = new FrameworkMethod(method); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } return delegate.apply(base, frameworkMethod, testInstance); } } }
@Override protected void starting(Description description) { System.out.println("\n[Test Case starting] " + description.getTestClass().getSimpleName() + "." + description.getMethodName() + "()\n"); }
@Override protected void finished(Description description) { System.out.println("\n[Test Case finished] " + description.getTestClass().getSimpleName() + "." + description.getMethodName() + "()\n"); }
Class<?> testClass = description.getTestClass(); if (logger.isDebugEnabled()) { logger.debug("Applying SpringClassRule to test class [" + testClass.getName() + "]");
/** * Get the test name from the JUnit Description * * @return the string for the short test name */ private String descriptionToShortTestName( org.junit.runner.Description description) { final int toRemove = "org.apache.hadoop.hbase.".length(); return description.getTestClass().getName().substring(toRemove) + "#" + description.getMethodName(); }
@Override public Statement apply( Statement base, Description description ) { testName = description.getDisplayName(); logger = Logger.getLogger( description.getTestClass().getName() ); logger.setLevel( level ); return super.apply( base, description ); }
@Override public Statement apply(Statement base, Description desc) { return ClassRuleWrapper.evaluate(base, desc.getTestClass(), 60); } };
private URL getScriptForTestMethod(Description description) { String name = description.getTestClass().getSimpleName() + "-" + removeGradleVersion(description.getMethodName()) + this.dsl.getExtension(); return description.getTestClass().getResource(name); }
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) { return Suite.emptySuite(); } if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) { // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); } Class<?> type = each.getTestClass(); if (type == null) { throw new RuntimeException("Can't build a runner from description [" + each + "]"); } String methodName = each.getMethodName(); if (methodName == null) { return Request.aClass(type).getRunner(); } return Request.method(type, methodName).getRunner(); }
private static RunCondition getIgnoreConditionOnClass(Description aDescription) { ConditionalRun[] annotations = aDescription.getTestClass().getAnnotationsByType(ConditionalRun.class); return new IgnoreConditionCreator(aDescription.getTestClass(), annotations).create(); }
private void directoryForDescription( Description description ) throws IOException { prepareDirectory( description.getTestClass(), description.getMethodName() ); }
private static RunCondition getIgnoreConditionOnMethod(Description aDescription) { try { // this is possible because test methods must not have any argument ConditionalRun[] annotations = aDescription.getTestClass().getMethod(aDescription.getMethodName()).getAnnotationsByType(ConditionalRun.class); return new IgnoreConditionCreator(aDescription.getTestClass(), annotations).create(); } catch (NoSuchMethodException | SecurityException ex) { throw new RuntimeException(ex); } }
private URL findDefaultScript(Description description) { URL scriptUrl = getScriptForTestMethod(description); if (scriptUrl != null) { return scriptUrl; } return getScriptForTestClass(description.getTestClass()); }
private static boolean hasConditionalIgnoreAnnotationOnMethod(Description aDescription) { if (aDescription.getMethodName() == null) { // if @ClassRule is used return false; } try { // this is possible because test methods must not have any argument Method testMethod = aDescription.getTestClass().getMethod(aDescription.getMethodName()); return testMethod.getAnnotationsByType(ConditionalRun.class).length > 0; } catch (NoSuchMethodException | SecurityException ex) { throw new RuntimeException(ex); } }