anchor.diff:  //import org.junit.Before; // JUnit 4
   import org.junit.jupiter.api.AfterEach;  // JUnit 5
   import org.junit.jupiter.api.BeforeEach; // JUnit 5
  -
  -final PrintStream originalOut = System.out;
  -final PrintStream originalErr = System.err;
  -final ByteArrayOutputStream out = new ByteArrayOutputStream();
  -final ByteArrayOutputStream err = new ByteArrayOutputStream();
  -
  -//@Before   // JUnit 4
  -@BeforeEach // JUnit 5
  -public void setUpStreams() {
  -    out.reset();
  -    err.reset();
  -    System.setOut(new PrintStream(out));
  -    System.setErr(new PrintStream(err));
  -}
  -
  -//@After   // JUnit 4
  -@AfterEach // JUnit 5
  -public void restoreStreams() {
  -    System.setOut(originalOut);
  -    System.setErr(originalErr);
  -}
  -
  -@Test
  -public void test() {
  -    String[] args = "my command args".split(" ");
  -    new CommandLine(new MyApp()).execute(args);
  -    assertEquals("MY COMMAND OUTPUT", out.toString());
  -    assertEquals("", err.toString());
  +//...
  +class TestOutput {
  +    final PrintStream originalOut = System.out;
  +    final PrintStream originalErr = System.err;
  +    final ByteArrayOutputStream out = new ByteArrayOutputStream();
  +    final ByteArrayOutputStream err = new ByteArrayOutputStream();
  +
  +    //@Before   // JUnit 4
  +    @BeforeEach // JUnit 5
  +    public void setUpStreams() {
  +        out.reset();
  +        err.reset();
  +        System.setOut(new PrintStream(out));
  +        System.setErr(new PrintStream(err));
  +    }
  +
  +    //@After   // JUnit 4
  +    @AfterEach // JUnit 5
  +    public void restoreStreams() {
  +        System.setOut(originalOut);
  +        System.setErr(originalErr);
  +    }
  +
  +    @Test
  +    public void test() {
  +        String[] args = "my command args".split(" ");
  +        new CommandLine(new MyApp()).execute(args);
  +        assertEquals("MY COMMAND OUTPUT", out.toString());
  +        assertEquals("", err.toString());
  +    }
   }
   ----
   
  
positive.code: 
  [source,java]
  ----
  StringWriter sw = new StringWriter();
  MyApp app = new MyApp();
  CommandLine cmd = new CommandLine(app);
  cmd.setOut(new PrintWriter(sw));
  
  // black box testing
  
negative.code: 
      public void run() {
          // make testing easier by printing to the Err and Out streams provided by picocli
          spec.commandLine().getOut().println("Your output is abc...");
      }
  }
  ----
  