@Override protected Description describeChild(FrameworkMethod child) { return Description.createTestDescription(child.getDeclaringClass(), child.getName()); }
@Override public void evaluate() throws Throwable { Locale original = Locale.getDefault(); System.out.println(String.format("Original locale: %s", original.toString())); for (Locale locale : locales) { Locale.setDefault(locale); System.out.println("Locale set to: " + Locale.getDefault().toString()); try { if (target instanceof LocaleTestingSetupAndTeardown) { ((LocaleTestingSetupAndTeardown) target).setupForRepeatedTestCase(); System.out.println("Running test..." + method.getDeclaringClass().getCanonicalName() + " : " + method.getName()); base.evaluate(); ((LocaleTestingSetupAndTeardown) target) .teardownForRepeatedTestCase(); } else { base.evaluate(); } } catch (Exception e) { System.out.println(String.format( "Test method '%s' failed with locale '%s'", method.getName(), locale.toString())); throw e; } } Locale.setDefault(original); System.out.println("Locale set back to: " + Locale.getDefault().toString()); }
System.out.println("Running test..." method.getDeclaringClass() .getCanonicalName() + " : "
private void noStrategyFound() { throw new IllegalStateException(format("Method %s#%s is annotated with @Parameters but there were no parameters provided.", frameworkMethod.getDeclaringClass().getName(), frameworkMethod.getName())); }
@SuppressWarnings("unchecked") public static <A extends Annotation> List<A> getParameterAnnotationsFrom(FrameworkMethod method, Class<A> annotationClass) { return Stream.of(method.getMethod().getParameterAnnotations()) .map((Function<Annotation[], List<? extends Annotation>>) Arrays::asList) .map( (List<? extends Annotation> annotations) -> (A) annotations.stream( ).filter( (Annotation eachAnnotation) -> annotationClass.isAssignableFrom(eachAnnotation.getClass()) ).findFirst( ).orElseThrow( () -> parameterWithoutAnnotation( format( "%s.%s", method.getDeclaringClass().getCanonicalName(), method.getName() ))) ).collect(toList()); } }
@SuppressWarnings("unchecked") public static <A extends Annotation> List<A> getParameterAnnotationsFrom(FrameworkMethod method, Class<A> annotationClass) { return Stream.of(method.getMethod().getParameterAnnotations()) .map((Function<Annotation[], List<? extends Annotation>>) Arrays::asList) .map( (List<? extends Annotation> annotations) -> (A) annotations.stream( ).filter( (Annotation eachAnnotation) -> annotationClass.isAssignableFrom(eachAnnotation.getClass()) ).findFirst( ).orElseThrow( () -> parameterWithoutAnnotation( format( "%s.%s", method.getDeclaringClass().getCanonicalName(), method.getName() ))) ).collect(toList()); } }
@Override public List<Exception> validateAnnotatedMethod(FrameworkMethod method) { return validate(method.getAnnotation(Given.class), new TestClass(method.getDeclaringClass())); }
@Override public List<Exception> validateAnnotatedMethod(FrameworkMethod method) { return validate(method.getAnnotation(Given.class), new TestClass(method.getDeclaringClass())); }
public List<Exception> validateAnnotatedMethod(FrameworkMethod method) { List<Exception> errors = new LinkedList<Exception>(); Class testClass = method.getDeclaringClass(); if (!method.isPublic()) { errors.add(new Exception(String.format(
configuration = TestConfiguration.fromIgnoreForUsers( ignoreForUsersAnnotation, Optional.ofNullable(frameworkMethod.getDeclaringClass().getAnnotation(RunWithUsers.class)) ); } else {
@Override protected Description describeChild(RdfUnitJunitTestCase child) { return Description.createTestDescription( child.getTestInputMethod().getDeclaringClass(), String.format( "[%s] %s", getTestInputBaseName(child.getTestInputMethod()), child.getTestCase().getResultMessage() ) ); }
@Override protected Description describeChild(RdfUnitJunitTestCase child) { return Description.createTestDescription( child.getTestInputMethod().getDeclaringClass(), String.format( "[%s] %s", getTestInputBaseName(child.getTestInputMethod()), child.getTestCase().getResultMessage() ) ); }
method.getMethod().getDeclaringClass().getPackage().getName())); } else { interceptedMethods.add(new CitrusFrameworkMethod(method.getMethod(), method.getDeclaringClass().getSimpleName() + "." + method.getName(), method.getMethod().getDeclaringClass().getPackage().getName()));
public MethodIsSkippable(FrameworkMethod method) { this.testClass = method.getDeclaringClass(); this.methodName = method.getName(); this.classNameIsSkippable = new ClassNameIsSkippable( testClass ); }
@Override protected Statement methodInvoker(FrameworkMethod method, Object test) { JavaBasedTest javaBasedTest = new JavaBasedTest( method.getName() + idGenerator.incrementAndGet(), method.getName()); ReportTestEntry reportTestEntry = javaBasedTest.getReportTestEntry(); reportTestEntry.setClassName(method.getDeclaringClass().getCanonicalName()); Statement runStatement = super.methodInvoker(method, test); return new Statement() { @Override public void evaluate() throws Throwable { beforeTestRun(javaBasedTest); try { runStatement.evaluate(); } catch (Throwable e) { reportTestEntry.setException(e); throw e; } finally { afterTestRun(javaBasedTest); } } }; }
@Override protected Statement methodInvoker(FrameworkMethod method, Object test) { JavaBasedTest javaBasedTest = new JavaBasedTest( method.getName() + idGenerator.incrementAndGet(), method.getName()); ReportTestEntry reportTestEntry = javaBasedTest.getReportTestEntry(); reportTestEntry.setClassName(method.getDeclaringClass().getCanonicalName()); Statement runStatement = super.methodInvoker(method, test); return new Statement() { @Override public void evaluate() throws Throwable { beforeTestRun(javaBasedTest); try { runStatement.evaluate(); } catch (Throwable e) { reportTestEntry.setException(e); throw e; } finally { afterTestRun(javaBasedTest); } } }; }
protected void runChild(FrameworkMethod method, RunNotifier notifier) { if (NoTestsFrameworkMethod.class.getName().equals(method.getDeclaringClass().getName())) { Description description = describeChild(method); notifier.fireTestStarted(description);
@Override protected void runChild(FrameworkMethod method, RunNotifier notifier) { AcceptanceTest root = method.getDeclaringClass().getAnnotation(AcceptanceTest.class); AcceptanceTest item = method.getAnnotation(AcceptanceTest.class); Description description = describeChild(method); if (!config.acceptTest(root, item)) { notifier.fireTestIgnored(description); return; } // Default logger.info("\n\n[TEST] " + description + "\n"); // Context AcceptanceRunContext.instance.set( new AcceptanceRunContext(description.getDisplayName()) ); // Running super.runChild(method, notifier); }
TestClass testClass = new TestClass(method.getDeclaringClass()); Method testMethod = method.getMethod();
TestClass testClass = new TestClass(method.getDeclaringClass()); Method testMethod = method.getMethod();