Search in sources :

Example 1 with OutputCapture

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);
}
Also used : Statement(org.junit.runners.model.Statement) OutputCapture(org.springframework.boot.test.rule.OutputCapture)

Aggregations

Statement (org.junit.runners.model.Statement)1 OutputCapture (org.springframework.boot.test.rule.OutputCapture)1