eclipsesource/restfuse — Issue #11: The custom ClassRunner for the unit tests does not support Spring
Author: mirkojahn
Created: 2012-03-09 00:13:19+00:00
State: open

While using the custom runner is really convenient, it prevents one from using bean wiring with springs own extension. I propose to expose another runner that actually combines both (I sketched a simple example below, which I tested successfully).

```java
// extend from the Spring version found in org.springframework.test.context.junit4.SpringJUnit4ClassRunner
// Maven coordinates for the library: GroupId: org.springframework ArtifactId: spring-test Version: 3.0.6.RELEASE Type: jar
public class SpringJUnit4HttpClassRunner extends SpringJUnit4ClassRunner {

public SpringJUnit4HttpClassRunner(Class clazz) throws InitializationError {
super(clazz);
}

@Override
protected List computeTestMethods() {
ArrayList result = new ArrayList(20);
result.addAll(getTestClass().getAnnotatedMethods(HttpTest.class));
List testAnnotatedMethods = getTestClass().getAnnotatedMethods(Test.class);
for (FrameworkMethod method : testAnnotatedMethods) {
if (!result.contains(method)) {
result.add(method);
}
}
return result;
}
}
```
I hope that helps...

Cheers,
Mirko