Coverage Report - org.apache.maven.surefire.suite.RunResult
 
Classes in this File Line Coverage Branch Coverage Complexity
RunResult
0%
0/36
0%
0/20
1.429
 
 1  
 package org.apache.maven.surefire.suite;
 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 java.util.StringTokenizer;
 23  
 
 24  
 /**
 25  
  * Represents a test-run-result; this may be from a single test run or an aggregated result.
 26  
  *
 27  
  * @author Kristian Rosenvold
 28  
  */
 29  
 public class RunResult
 30  
 {
 31  
     private final int completedCount;
 32  
 
 33  
     private final int errors;
 34  
 
 35  
     private final int failures;
 36  
 
 37  
     private final int skipped;
 38  
 
 39  
     private final boolean failure;
 40  
 
 41  
     private final boolean timeout;
 42  
 
 43  
     public static final int SUCCESS = 0;
 44  
 
 45  
     private static final int FAILURE = 255;
 46  
 
 47  
     private static final int NO_TESTS = 254;
 48  
 
 49  0
     public static final RunResult Timeout = new RunResult( 0, 0, 0, 0, false, true );
 50  
 
 51  
     public RunResult( int completedCount, int errors, int failures, int skipped )
 52  
     {
 53  0
         this( completedCount, errors, failures, skipped, false, false );
 54  0
     }
 55  
 
 56  
     public RunResult( int completedCount, int errors, int failures, int skipped, boolean failure, boolean timeout )
 57  0
     {
 58  0
         this.completedCount = completedCount;
 59  0
         this.errors = errors;
 60  0
         this.failures = failures;
 61  0
         this.skipped = skipped;
 62  0
         this.failure = failure;
 63  0
         this.timeout = timeout;
 64  0
     }
 65  
 
 66  
     public int getCompletedCount()
 67  
     {
 68  0
         return completedCount;
 69  
     }
 70  
 
 71  
     public int getErrors()
 72  
     {
 73  0
         return errors;
 74  
     }
 75  
 
 76  
     public int getFailures()
 77  
     {
 78  0
         return failures;
 79  
     }
 80  
 
 81  
     public int getSkipped()
 82  
     {
 83  0
         return skipped;
 84  
     }
 85  
 
 86  
     public int getForkedProcessCode()
 87  
     {
 88  0
         return completedCount == 0 ? NO_TESTS : isErrrorFree() ? SUCCESS : FAILURE;
 89  
     }
 90  
 
 91  
     public boolean isErrrorFree()
 92  
     {
 93  0
         return getFailures() == 0 && getErrors() == 0;
 94  
     }
 95  
 
 96  
     public String getAsString()
 97  
     {
 98  0
         return getCompletedCount() + "," + getErrors() + "," + getFailures() + "," + getSkipped() + "," + isFailure()
 99  
             + "," + isTimeout();
 100  
     }
 101  
 
 102  
     public static RunResult fromString( String string )
 103  
     {
 104  0
         StringTokenizer strTok = new StringTokenizer( string, "," );
 105  0
         int completed = Integer.parseInt( strTok.nextToken() );
 106  0
         int errors = Integer.parseInt( strTok.nextToken() );
 107  0
         int failures = Integer.parseInt( strTok.nextToken() );
 108  0
         int skipped = Integer.parseInt( strTok.nextToken() );
 109  0
         boolean isFailure = Boolean.parseBoolean( strTok.nextToken() );
 110  0
         boolean isTimeout = Boolean.parseBoolean( strTok.nextToken() );
 111  0
         return new RunResult( completed, errors, failures, skipped, isFailure, isTimeout );
 112  
     }
 113  
 
 114  
     public boolean isFailureOrTimeout()
 115  
     {
 116  0
         return this.timeout || this.failure;
 117  
     }
 118  
 
 119  
     public boolean isFailure()
 120  
     {
 121  0
         return failure;
 122  
     }
 123  
 
 124  
     public boolean isTimeout()
 125  
     {
 126  0
         return timeout;
 127  
     }
 128  
 
 129  
 
 130  
     public RunResult aggregate( RunResult other )
 131  
     {
 132  0
         boolean failure = isFailure() || other.isFailure();
 133  0
         boolean timeout = isTimeout() || other.isTimeout();
 134  0
         int completed = getCompletedCount() + other.getCompletedCount();
 135  0
         int fail = getFailures() + other.getFailures();
 136  0
         int ign = getSkipped() + other.getSkipped();
 137  0
         int err = getErrors() + other.getErrors();
 138  0
         return new RunResult( completed, err, fail, ign, failure, timeout );
 139  
     }
 140  
 }