maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r415196 - in /maven/surefire/trunk/surefire-api/src: main/java/org/apache/maven/surefire/report/ test/java/org/apache/maven/surefire/report/
Date Sun, 18 Jun 2006 21:11:25 GMT
Author: carlos
Date: Sun Jun 18 14:11:24 2006
New Revision: 415196

URL: http://svn.apache.org/viewvc?rev=415196&view=rev
Log:
Refactor and use static methods

Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTest.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java?rev=415196&r1=415195&r2=415196&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
Sun Jun 18 14:11:24 2006
@@ -93,7 +93,7 @@
      * @param report report whose test set is starting
      * @return the message
      */
-    public String getTestSetStartingMessage( ReportEntry report )
+    public static String getTestSetStartingMessage( ReportEntry report )
     {
         StringBuffer message = new StringBuffer();
         message.append( TEST_SET_STARTING_PREFIX );
@@ -115,7 +115,7 @@
      * @param message
      * @return the parsed {@link ReportEntry}
      */
-    public ReportEntry parseTestSetStartingMessage( String message )
+    public static ReportEntry parseTestSetStartingMessage( String message )
     {
         ReportEntry reportEntry = new ReportEntry();
         int i = message.indexOf( TEST_SET_STARTING_GROUP_PREFIX );
@@ -140,4 +140,17 @@
         reportEntry.setName( message.substring( TEST_SET_STARTING_PREFIX.length(), i ) );
         return reportEntry;
     }
+
+    /**
+     * Check if the String passed as argument is a "test starting" message.
+     * If so it can be passed to {@link #parseTestSetStartingMessage(String)}
+     * 
+     * @param message the message to check
+     * @return true if it is a "test starting" message
+     */
+    public static boolean isTestSetStartingMessage( String message )
+    {
+        return message.startsWith( TEST_SET_STARTING_PREFIX );
+    }
+
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java?rev=415196&r1=415195&r2=415196&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
Sun Jun 18 14:11:24 2006
@@ -37,6 +37,8 @@
 
     protected PrintWriter writer;
 
+    private static final String TEST_SET_COMPLETED_PREFIX = "Tests run: ";
+
     private final String format;
 
     private List testResults;
@@ -134,7 +136,7 @@
     {
         StringBuffer buf = new StringBuffer();
 
-        buf.append( "Tests run: " );
+        buf.append( TEST_SET_COMPLETED_PREFIX );
         buf.append( completedCount );
         buf.append( ", Failures: " );
         buf.append( failures );
@@ -179,4 +181,16 @@
 
         return buf.toString();
     }
+
+    /**
+     * Check if the String passed as argument is a "test set completed" message.
+     * 
+     * @param message the message to check
+     * @return true if it is a "test set completed" message
+     */
+    public static boolean isTestSetCompletedMessage( String message )
+    {
+        return message.startsWith( TEST_SET_COMPLETED_PREFIX );
+    }
+
 }

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTest.java?rev=415196&r1=415195&r2=415196&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTest.java
(original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AbstractConsoleReporterTest.java
Sun Jun 18 14:11:24 2006
@@ -60,11 +60,11 @@
     public void testGetTestSetStartingMessage()
         throws Exception
     {
-        String message = consoleReporter.getTestSetStartingMessage( report );
+        String message = AbstractConsoleReporter.getTestSetStartingMessage( report );
         assertEquals( "Running name (of group)", message );
 
         report.setGroup( null );
-        message = consoleReporter.getTestSetStartingMessage( report );
+        message = AbstractConsoleReporter.getTestSetStartingMessage( report );
         assertEquals( "Running name", message );
     }
 
@@ -72,13 +72,26 @@
         throws Exception
     {
         String message = "Running name (of group)";
-        ReportEntry actualReport = consoleReporter.parseTestSetStartingMessage( message );
+        ReportEntry actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message
);
         assertEquals( report, actualReport );
 
         report.setGroup( null );
         message = "Running name";
-        actualReport = consoleReporter.parseTestSetStartingMessage( message );
+        actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
         assertEquals( report, actualReport );
+    }
+
+    public void testIsTestSetStartingMessage()
+        throws Exception
+    {
+        String message = "Running name (of group)";
+        assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
+
+        message = "Running name";
+        assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
+
+        message = "Xxxx";
+        assertFalse( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
     }
 
 }



Mime
View raw message