Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TestResult.cpp
00001 /* 00002 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of the <organization> nor the 00013 * names of its contributors may be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 00017 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY 00020 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00025 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00028 #include "CppUTest/TestHarness.h" 00029 #include "CppUTest/TestResult.h" 00030 #include "CppUTest/TestFailure.h" 00031 #include "CppUTest/TestOutput.h" 00032 #include "CppUTest/PlatformSpecificFunctions.h" 00033 00034 TestResult::TestResult(TestOutput& p) : 00035 output_(p), testCount_(0), runCount_(0), checkCount_(0), failureCount_(0), filteredOutCount_(0), ignoredCount_(0), totalExecutionTime_(0), timeStarted_(0), currentTestTimeStarted_(0), 00036 currentTestTotalExecutionTime_(0), currentGroupTimeStarted_(0), currentGroupTotalExecutionTime_(0) 00037 { 00038 } 00039 00040 void TestResult::setProgressIndicator(const char* indicator) 00041 { 00042 output_.setProgressIndicator(indicator); 00043 } 00044 00045 TestResult::~TestResult() 00046 { 00047 } 00048 00049 void TestResult::currentGroupStarted(UtestShell* test) 00050 { 00051 output_.printCurrentGroupStarted(*test); 00052 currentGroupTimeStarted_ = GetPlatformSpecificTimeInMillis(); 00053 } 00054 00055 void TestResult::currentGroupEnded(UtestShell* /*test*/) 00056 { 00057 currentGroupTotalExecutionTime_ = GetPlatformSpecificTimeInMillis() - currentGroupTimeStarted_; 00058 output_.printCurrentGroupEnded(*this); 00059 } 00060 00061 void TestResult::currentTestStarted(UtestShell* test) 00062 { 00063 output_.printCurrentTestStarted(*test); 00064 currentTestTimeStarted_ = GetPlatformSpecificTimeInMillis(); 00065 } 00066 00067 void TestResult::print(const char* text) 00068 { 00069 output_.print(text); 00070 } 00071 00072 void TestResult::currentTestEnded(UtestShell* /*test*/) 00073 { 00074 currentTestTotalExecutionTime_ = GetPlatformSpecificTimeInMillis() - currentTestTimeStarted_; 00075 output_.printCurrentTestEnded(*this); 00076 00077 } 00078 00079 void TestResult::addFailure(const TestFailure& failure) 00080 { 00081 output_.print(failure); 00082 failureCount_++; 00083 } 00084 00085 void TestResult::countTest() 00086 { 00087 testCount_++; 00088 } 00089 00090 void TestResult::countRun() 00091 { 00092 runCount_++; 00093 } 00094 00095 void TestResult::countCheck() 00096 { 00097 checkCount_++; 00098 } 00099 00100 void TestResult::countFilteredOut() 00101 { 00102 filteredOutCount_++; 00103 } 00104 00105 void TestResult::countIgnored() 00106 { 00107 ignoredCount_++; 00108 } 00109 00110 void TestResult::testsStarted() 00111 { 00112 timeStarted_ = GetPlatformSpecificTimeInMillis(); 00113 output_.printTestsStarted(); 00114 } 00115 00116 void TestResult::testsEnded() 00117 { 00118 long timeEnded = GetPlatformSpecificTimeInMillis(); 00119 totalExecutionTime_ = timeEnded - timeStarted_; 00120 output_.printTestsEnded(*this); 00121 } 00122 00123 long TestResult::getTotalExecutionTime() const 00124 { 00125 return totalExecutionTime_; 00126 } 00127 00128 void TestResult::setTotalExecutionTime(long exTime) 00129 { 00130 totalExecutionTime_ = exTime; 00131 } 00132 00133 long TestResult::getCurrentTestTotalExecutionTime() const 00134 { 00135 return currentTestTotalExecutionTime_; 00136 } 00137 00138 long TestResult::getCurrentGroupTotalExecutionTime() const 00139 { 00140 return currentGroupTotalExecutionTime_; 00141 } 00142
Generated on Fri Jul 15 2022 01:46:33 by
1.7.2