Coverage Report - org.apache.maven.surefire.report.TestSetStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
TestSetStatistics
0 %
0/20
0 %
0/4
1
 
 1  
 package org.apache.maven.surefire.report;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *     http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.surefire.suite.RunResult;
 23  
 
 24  
 import java.util.Properties;
 25  
 
 26  
 /**
 27  
  * Run-statistics for a testset
 28  
  *
 29  
  * @author Kristian Rosenvold
 30  
  *         Note; synchronization is questionable. Whiled this class alone is ok, there's a higher level concern about
 31  
  *         synchronization interactions within ReporterManager. See ReporterManager class.
 32  
  */
 33  0
 public class TestSetStatistics
 34  
 {
 35  
     private static final String RESULTS_ERRORS = "errors";
 36  
 
 37  
     private static final String RESULTS_COMPLETED_COUNT = "completedCount";
 38  
 
 39  
     private static final String RESULTS_FAILURES = "failures";
 40  
 
 41  
     private static final String RESULTS_SKIPPED = "skipped";
 42  
 
 43  
 
 44  
     private int completedCount;
 45  
 
 46  
     private int errors;
 47  
 
 48  
     private int failures;
 49  
 
 50  
     private int skipped;
 51  
 
 52  
     public synchronized void incrementCompletedCount()
 53  
     {
 54  0
         completedCount += 1;
 55  0
     }
 56  
 
 57  
     public synchronized void incrementErrorsCount()
 58  
     {
 59  0
         errors += 1;
 60  0
     }
 61  
 
 62  
     public synchronized void incrementFailureCount()
 63  
     {
 64  0
         failures += 1;
 65  0
     }
 66  
 
 67  
     public synchronized void incrementSkippedCount()
 68  
     {
 69  0
         skipped += 1;
 70  0
     }
 71  
 
 72  
     public synchronized boolean hadFailures()
 73  
     {
 74  0
         return failures > 0;
 75  
     }
 76  
 
 77  
     public synchronized boolean hadErrors()
 78  
     {
 79  0
         return errors > 0;
 80  
     }
 81  
 
 82  
     public synchronized int getCompletedCount()
 83  
     {
 84  0
         return completedCount;
 85  
     }
 86  
 
 87  
     public int getSkipped()
 88  
     {
 89  0
         return skipped;
 90  
     }
 91  
 
 92  
     public synchronized void initResultsFromProperties( Properties results )
 93  
     {
 94  0
         errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue();
 95  0
         skipped = Integer.valueOf( results.getProperty( RESULTS_SKIPPED, "0" ) ).intValue();
 96  0
         failures = Integer.valueOf( results.getProperty( RESULTS_FAILURES, "0" ) ).intValue();
 97  0
         completedCount = Integer.valueOf( results.getProperty( RESULTS_COMPLETED_COUNT, "0" ) ).intValue();
 98  0
     }
 99  
 
 100  
 
 101  
     public synchronized RunResult getRunResult()
 102  
     {
 103  0
         return new RunResult( completedCount, errors, failures, skipped );
 104  
     }
 105  
 
 106  
     public synchronized String getSummary()
 107  
     {
 108  0
         return "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: "
 109  
             + skipped;
 110  
     }
 111  
 
 112  
 }