1// 2// MuleUnit: A minimalistic C++ Unit testing framework based on EasyUnit. 3// 4// Copyright (c) 2005-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5// Copyright (c) 2004-2011 Barthelemy Dagenais ( barthelemy@prologique.com ) 6// 7// This library is free software; you can redistribute it and/or 8// modify it under the terms of the GNU Lesser General Public 9// License as published by the Free Software Foundation; either 10// version 2.1 of the License, or (at your option) any later version. 11// 12// This library is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15// Lesser General Public License for more details. 16// 17// You should have received a copy of the GNU Lesser General Public 18// License along with this library; if not, write to the Free Software 19// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20// 21 22 23#ifndef TESTCASE_H 24#define TESTCASE_H 25 26 27#include <wx/string.h> 28#include <list> 29 30 31namespace muleunit 32{ 33 34class Test; 35 36typedef std::list<Test*> TestList; 37 38 39/** 40 * A TestCase is a collection of unit tests (instance of Test) and is 41 * always specified by the first parameter of a Test declaration. 42 */ 43class TestCase 44{ 45public: 46 47 /** 48 * Main TestCase constructor. 49 * 50 * @param name TestCase name 51 */ 52 TestCase(const wxString& name); 53 54 virtual ~TestCase(); 55 56 /** 57 * Add a Test to the Test list. This method is used by TestRegistry. 58 * 59 * @param test Test instance to add to the Test list. 60 */ 61 void addTest(Test *test); 62 63 /** 64 * Get the Test list. 65 * 66 * @return Test list 67 */ 68 const TestList& getTests() const; 69 70 /** 71 * Execute all Tests in the Test list of this TestCase, returning false if there were failures. 72 */ 73 bool run(); 74 75 /** 76 * Get the Test list size (number of Tests in this TestCase). 77 * 78 * @return The Test list size 79 */ 80 int getTestsCount() const; 81 82 /** 83 * Get the total number of failures reported by all Tests. 84 * 85 * @return The total number of failures reported by all Tests. 0 86 * if no test were run or if no failures were reported. 87 */ 88 int getFailuresCount() const; 89 90 /** 91 * Get the total number of successes reported by all Tests. 92 * 93 * @return The total number of successes reported by all Tests. 0 94 * if no test were run or if no successes were reported. 95 */ 96 int getSuccessesCount() const; 97 98 /** 99 * Get the TestCase name. This name is specified by the first parameter 100 * of the Test declaration. For example, if a test was declared as 101 * TEST(TESTCASE1, TEST1), the TestCase name would be "TESTCASE1". 102 * 103 * @return The name of the TestCase 104 */ 105 const wxString& getName() const; 106 107protected: 108 int m_failuresCount; 109 int m_successesCount; 110 TestList m_tests; 111 wxString m_name; 112 113private: 114 void runTests(Test *test); 115}; 116 117} // MuleUnit ns 118#endif // TESTCASE_H 119 120