It took me a while before I really understood what this @Rule business in JUnit 4.7 is really about, but I like it!
Creating a Web Server
interface MethodRule {
Statement apply(final Statement base, FrameworkMethod method, Object target)
}
@Rule
public WebServer server =
new WebServer("WEBSERVER_PORT", 9191);
Environment Variables?
Which Resource?
Annotations to the rescue
@Test
@WebResource(content="classpath:whatever.xml", contentType="text/xml")
public void shouldBeAbleToDealWithWhatever {
String url = server.getURL();
// Download something from that URL using your client
}
Conclusions
Filed under Java | No Comments »