Tibor17 commented on a change in pull request #11: [SUREFIRE-1556] fail fast on 
empty element names
URL: https://github.com/apache/maven-shared-utils/pull/11#discussion_r383458678
 
 

 ##########
 File path: 
src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java
 ##########
 @@ -40,26 +37,24 @@
  */
 public class PrettyPrintXmlWriterTest
 {
-    StringWriter w;
+    private StringWriter w = new StringWriter();;
 
-    PrettyPrintXMLWriter writer;
+    private PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( w );
 
-    @Before
-    public void before()
-            throws Exception
-    {
-        w = new StringWriter();
-        writer = new PrettyPrintXMLWriter( w );
-    }
-
-    @After
-    public void after()
-            throws Exception
+    
+    @Test
 
 Review comment:
   @elharo 
   I am a practicle man. You can of course use [1] with anonymous class instead 
of Lambda but you can use a traditional ExpectedException with the old version 
of JUnit.
   [1]: 
https://junit.org/junit4/javadoc/4.13/org/junit/Assert.html#assertThrows(java.lang.String,%20java.lang.Class,%20org.junit.function.ThrowingRunnable)
   
   ```
   import org.junit.rules.ExpectedException;
   
   import static org.hamcrest.Matchers.equalTo;
   
       @Rule
       public final ExpectedException e = ExpectedException.none();
   
       @Test
       public void testNoStartTag() throws IOException
       {
           e.expect( IllegalArgumentException.class );
           e.expectMessage( equalTo( "Element name cannot be empty" ) );
           writer.startElement( "" );
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to