use of org.springframework.boot.test.rule.OutputCapture in project spring-boot by spring-projects.
the class WebMvcTestPrintDefaultRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod frameworkMethod) {
Statement statement = super.methodBlock(frameworkMethod);
statement = new AlwaysPassStatement(statement);
OutputCapture outputCapture = new OutputCapture();
if (frameworkMethod.getName().equals("shouldPrint")) {
outputCapture.expect(containsString("HTTP Method"));
} else if (frameworkMethod.getName().equals("shouldNotPrint")) {
outputCapture.expect(not(containsString("HTTP Method")));
} else {
throw new IllegalStateException("Unexpected test method");
}
System.err.println(frameworkMethod.getName());
return outputCapture.apply(statement, null);
}
Aggregations