JUnit IgnoreRest - turn 2
In the previous IgnoreRest article I was complaining about that it is not notifying IDE properly without a custom test runner.
So I have implemented the runner I need.
1 public class IgnoreRestSupportRunner extends BlockJUnit4ClassRunner { 2 public IgnoreRestSupportRunner(Class<?> klass) throws InitializationError { 3 super(klass); 4 } 5 6 @Override 7 protected void runChild(final FrameworkMethod method, RunNotifier notifier) { 8 IgnoreRest ignoreRestAnnotation = method.getAnnotation(IgnoreRest.class); 9 Description description = describeChild(method); 10 if (IgnoreRestHelper.hasIgnoreRestAnnotation(description) && null == ignoreRestAnnotation) { 11 notifier.fireTestIgnored(description); 12 } 13 else { 14 super.runChild(method, notifier); 15 } 16 } 17 }
And that is all. Nothing else. All the remining code needed is extracted from the previous implementation. For supporting Spring I have to make use exactly the same code but the base class has to be SpringJUnit4ClassRunner
.
So the only runner I have to deal with is the junit-hierarchicalcontextrunner .
Source is available on GitHub
Aug 31, 2014
comments powered by Disqus