@@ -29,23 +29,28 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2929import org .apache .commons .cli .help .TableDefinition ;
3030import org .apache .commons .cli .help .TextStyle ;
3131import org .apache .commons .io .IOUtils ;
32+ import org .junit .jupiter .api .BeforeEach ;
3233import org .junit .jupiter .api .Test ;
3334
3435public class AptHelpAppendableTest {
3536
36- private final StringBuilder sb = new StringBuilder ();
37- private final AptHelpAppendable underTest = new AptHelpAppendable (sb );
37+ private StringBuilder sb ;
38+ private AptHelpAppendable underTest ;
39+
40+ @ BeforeEach
41+ public void beforeEach () {
42+ sb = new StringBuilder ();
43+ underTest = new AptHelpAppendable (sb );
44+ }
3845
3946 @ Test
4047 public void testAppendFormatTest () throws IOException {
41- sb .setLength (0 );
4248 underTest .appendFormat ("Big %s and Phantom %,d" , "Joe" , 309 );
4349 assertEquals (String .format ("Big Joe and Phantom 309" ), sb .toString ());
4450 }
4551
4652 @ Test
4753 public void testAppendHeaderTest () throws IOException {
48- sb .setLength (0 );
4954 underTest .appendHeader (1 , "Hello World" );
5055 assertEquals (String .format ("* Hello World%n%n" ), sb .toString ());
5156 sb .setLength (0 );
@@ -58,7 +63,6 @@ public void testAppendHeaderTest() throws IOException {
5863 @ Test
5964 public void testAppendListTest () throws IOException {
6065 final String [] entries = { "one" , "two" , "three" };
61- sb .setLength (0 );
6266 underTest .appendList (true , Arrays .asList (entries ));
6367 assertEquals (String .format (" [[1]] one%n [[2]] two%n [[3]] three%n%n" ), sb .toString ());
6468 sb .setLength (0 );
@@ -68,14 +72,12 @@ public void testAppendListTest() throws IOException {
6872
6973 @ Test
7074 public void testAppendParagraphFormatTest () throws IOException {
71- sb .setLength (0 );
7275 underTest .appendParagraphFormat ("Hello %s World %,d" , "Big Joe" , 309 );
7376 assertEquals (String .format (" Hello Big Joe World 309%n%n" ), sb .toString ());
7477 }
7578
7679 @ Test
7780 public void testAppendParagraphTest () throws IOException {
78- sb .setLength (0 );
7981 underTest .appendParagraph ("Hello World" );
8082 assertEquals (String .format (" Hello World%n%n" ), sb .toString ());
8183 }
@@ -104,7 +106,6 @@ public void testAppendTableTest() throws IOException {
104106 expected .add ("The caption" );
105107 expected .add ("" );
106108 TableDefinition table = TableDefinition .from ("The caption" , styles , Arrays .asList (headers ), rows );
107- sb .setLength (0 );
108109 underTest .appendTable (table );
109110 List <String > actual = IOUtils .readLines (new StringReader (sb .toString ()));
110111 assertEquals (expected , actual , "full table failed" );
0 commit comments