Coverage Report - org.apache.maven.surefire.report.TestSetStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
TestSetStatistics
0%
0/25
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  
 /**
 25  
  * Run-statistics for a testset
 26  
  *
 27  
  * @author Kristian Rosenvold
 28  
  *         Note; synchronization is questionable. Whiled this class alone is ok, there's a higher level concern about
 29  
  *         synchronization interactions within ReporterManager. See ReporterManager class.
 30  
  */
 31  0
 public class TestSetStatistics
 32  
 {
 33  
     private int completedCount;
 34  
 
 35  
     private int errors;
 36  
 
 37  
     private int failures;
 38  
 
 39  
     private int skipped;
 40  
 
 41  
     public synchronized void incrementCompletedCount()
 42  
     {
 43  0
         completedCount += 1;
 44  0
     }
 45  
 
 46  
     public synchronized void incrementErrorsCount()
 47  
     {
 48  0
         errors += 1;
 49  0
     }
 50  
 
 51  
     public synchronized void incrementFailureCount()
 52  
     {
 53  0
         failures += 1;
 54  0
     }
 55  
 
 56  
     public synchronized void incrementSkippedCount()
 57  
     {
 58  0
         skipped += 1;
 59  0
     }
 60  
 
 61  
     public synchronized boolean hadFailures()
 62  
     {
 63  0
         return failures > 0;
 64  
     }
 65  
 
 66  
     public synchronized void reset()
 67  
     {
 68  0
         completedCount = 0;
 69  0
         errors = 0;
 70  0
         failures = 0;
 71  0
         skipped = 0;
 72  0
     }
 73  
 
 74  
     public synchronized boolean hadErrors()
 75  
     {
 76  0
         return errors > 0;
 77  
     }
 78  
 
 79  
     public synchronized int getCompletedCount()
 80  
     {
 81  0
         return completedCount;
 82  
     }
 83  
 
 84  
     public int getSkipped()
 85  
     {
 86  0
         return skipped;
 87  
     }
 88  
 
 89  
     public synchronized void add( TestSetStatistics testSetStatistics )
 90  
     {
 91  0
         this.completedCount += testSetStatistics.completedCount;
 92  0
         this.errors += testSetStatistics.errors;
 93  0
         this.failures += testSetStatistics.failures;
 94  0
         this.skipped += testSetStatistics.skipped;
 95  0
     }
 96  
 
 97  
     public synchronized RunResult getRunResult()
 98  
     {
 99  0
         return new RunResult( completedCount, errors, failures, skipped );
 100  
     }
 101  
 
 102  
     public synchronized String getSummary()
 103  
     {
 104  0
         return "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors + ", Skipped: "
 105  
             + skipped;
 106  
     }
 107  
 
 108  
 }