-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Labels
type: documentationA documentation updateA documentation update
Milestone
Description
Hi, I ran into this problem below:
For each test, it passes. But if I run the test class, it always failed on the 2nd. Any ideas?
Thanks
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.logging.AbstractLoggingSystemTests;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import java.util.logging.Logger;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(OutputCaptureExtension.class)
public class TestCapture extends AbstractLoggingSystemTests {
static Logger LOG=Logger.getLogger(TestCapture.class.getName());
@Test
void test(CapturedOutput output) {
System.out.println("ok");
LOG.warning("error");
assertThat(output).contains("ok");
assertThat(output).contains("error");
}
@Test
void test2(CapturedOutput output) {
LOG.info("not ok");
LOG.warning("type 1 error");
assertThat(output).contains("not");
assertThat(output).contains("type 1");
}
}
emeraldhieu and f0def
Metadata
Metadata
Assignees
Labels
type: documentationA documentation updateA documentation update