Commit 808b373d authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.1.x'

Closes gh-17552
parents 9d85dbad 9dabc0e1
......@@ -36,11 +36,12 @@ class MockMvcPrintOnlyOnFailureTestExecutionListener extends AbstractTestExecuti
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
if (testContext.getTestException() != null) {
DeferredLinesWriter writer = DeferredLinesWriter.get(testContext.getApplicationContext());
if (writer != null) {
DeferredLinesWriter writer = DeferredLinesWriter.get(testContext.getApplicationContext());
if (writer != null) {
if (testContext.getTestException() != null) {
writer.writeDeferredResult();
}
writer.clear();
}
}
......
......@@ -253,6 +253,10 @@ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomi
}
}
void clear() {
this.lines.clear();
}
}
/**
......
......@@ -16,7 +16,9 @@
package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.engine.discovery.DiscoverySelectors;
......@@ -43,6 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Andy Wilkinson
*/
@ExtendWith(OutputCaptureExtension.class)
@TestMethodOrder(MethodOrderer.Alphanumeric.class)
class WebMvcTestPrintDefaultIntegrationTests {
@Test
......@@ -54,7 +57,7 @@ class WebMvcTestPrintDefaultIntegrationTests {
@Test
void shouldPrint(CapturedOutput output) throws Throwable {
executeTests(ShouldPrint.class);
assertThat(output).contains("HTTP Method");
assertThat(output).containsOnlyOnce("HTTP Method");
}
private void executeTests(Class<?> testClass) throws Throwable {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment