mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
parent
8d4a2add63
commit
cdf43a7489
@ -18,9 +18,9 @@ package org.springframework.boot.test.system;
|
||||
|
||||
/**
|
||||
* Provides access to {@link System#out System.out} and {@link System#err System.err}
|
||||
* output that has been captured by the {@link OutputCaptureExtension}. Can be used to
|
||||
* apply assertions either using AssertJ or standard JUnit assertions. For example:
|
||||
* <pre class="code">
|
||||
* output that has been captured by the {@link OutputCaptureExtension} or
|
||||
* {@link OutputCaptureRule}. Can be used to apply assertions either using AssertJ or
|
||||
* standard JUnit assertions. For example: <pre class="code">
|
||||
* assertThat(output).contains("started"); // Checks all output
|
||||
* assertThat(output.getErr()).contains("failed"); // Only checks System.err
|
||||
* assertThat(output.getOut()).contains("ok"); // Only checks System.put
|
||||
|
@ -33,7 +33,7 @@ import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
* parameter resolution} for a {@link CapturedOutput} instance which can be used to assert
|
||||
* that the correct output was written.
|
||||
* <p>
|
||||
* To use with {@link ExtendWith @ExtendWith}, inject the {@link CapturedOutput} as an
|
||||
* To use, add {@link ExtendWith @ExtendWith} and inject the {@link CapturedOutput} as an
|
||||
* argument to your test class constructor or test method:
|
||||
*
|
||||
* <pre class="code">
|
||||
|
@ -83,7 +83,7 @@ public class OutputCaptureRule implements TestRule, CapturedOutput {
|
||||
|
||||
/**
|
||||
* Resets the current capture session, clearing its captured output.
|
||||
* @deprecated since 2.2 with no replacement
|
||||
* @deprecated since 2.2.0 with no replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public void reset() {
|
||||
|
@ -17,20 +17,13 @@
|
||||
package org.springframework.boot.testsupport.system;
|
||||
|
||||
/**
|
||||
* Provides access to {@link System#out System.out} and {@link System#err System.err}
|
||||
* output that has been capture by the {@link OutputCaptureExtension}. Can be used to
|
||||
* apply assertions either using AssertJ or standard JUnit assertions. For example:
|
||||
* <pre class="code">
|
||||
* assertThat(output).contains("started"); // Checks all output
|
||||
* assertThat(output.getErr()).contains("failed"); // Only checks System.err
|
||||
* assertThat(output.getOut()).contains("ok"); // Only checks System.put
|
||||
* </pre>
|
||||
* Internal test class providing access to {@link System#out System.out} and
|
||||
* {@link System#err System.err} output that has been captured.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.2.0
|
||||
* @see OutputCaptureExtension
|
||||
*/
|
||||
public interface CapturedOutput extends CharSequence {
|
||||
|
||||
|
@ -35,8 +35,6 @@ import org.springframework.util.Assert;
|
||||
* @author Madhura Bhave
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @see OutputCaptureExtension
|
||||
* @see OutputCaptureRule
|
||||
*/
|
||||
class OutputCapture implements CapturedOutput {
|
||||
|
||||
|
@ -20,7 +20,6 @@ import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
@ -28,31 +27,12 @@ import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
/**
|
||||
* Internal JUnit 5 {@code @Extension} to capture {@link System#out System.out} and
|
||||
* {@link System#err System.err}. Can be used on a test class via
|
||||
* {@link ExtendWith @ExtendWith}. This extension provides {@link ParameterResolver
|
||||
* parameter resolution} for a {@link CapturedOutput} instance which can be used to assert
|
||||
* that the correct output was written.
|
||||
* <p>
|
||||
* To use with {@link ExtendWith @ExtendWith}, inject the {@link CapturedOutput} as an
|
||||
* argument to your test class constructor or test method:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @ExtendWith(OutputCaptureExtension.class)
|
||||
* class MyTest {
|
||||
*
|
||||
* @Test
|
||||
* void test(CapturedOutput output) {
|
||||
* assertThat(output).contains("ok");
|
||||
* }
|
||||
*
|
||||
* }
|
||||
* </pre>
|
||||
* {@link System#err System.err}.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.2.0
|
||||
* @see CapturedOutput
|
||||
*/
|
||||
public class OutputCaptureExtension
|
||||
implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
|
||||
|
Loading…
Reference in New Issue
Block a user