10#include <QSharedPointer>
20#define TEST_CONCATENATE_DETAIL(x, y) x##y
21#define TEST_CONCATENATE(x, y) TEST_CONCATENATE_DETAIL(x, y)
22#define TEST_MAKE_UNIQUE(x) TEST_CONCATENATE(x, __COUNTER__)
24#define DECLARE_TEST(className) static edbee::test::Test<className> TEST_MAKE_UNIQUE(t)(#className)
25#define DECLARE_NAMED_TEST(name,className) static edbee::test::Test<className> TEST_MAKE_UNIQUE(name)(#className)
28namespace edbee {
namespace test {
42 return QStringLiteral(
"%1").arg(obj);
53 explicit TestResult(
TestCase* testCase,
const QString& methodName,
const QString& description,
const char* file,
int lineNumber );
56 virtual void setBooleanResult(
bool result,
const char *statement );
59 virtual void setCompareResult(
bool result,
const QString& actualValue,
const QString& expectedValue,
const char* actualStatement,
const char* expectedStatement );
67 virtual void setSkip();
72 virtual const char*
fileName() {
return fileNameRef_; }
77 virtual const char*
statement() {
return actualStatementRef_; }
91 const char* fileNameRef_;
95 bool compareStatement_;
96 const char* actualStatementRef_;
97 const char* expectedStatementRef_;
99 QString expectedValue_;
112#define GET_3TH_ARG(arg1, arg2, arg3, ...) arg3
113#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
116#define testTrue_1(statement) testTrueImpl( ( statement ) ? true : false, #statement, "", __FILE__, __LINE__)
117#define testTrue_2(statement, message) testTrueImpl( ( statement ) ? true : false, #statement, (message), __FILE__, __LINE__ )
118#define testTrue_MACRO_CHOOSER(...) \
119 GET_3TH_ARG(__VA_ARGS__, testTrue_2, testTrue_1, )
118#define testTrue_MACRO_CHOOSER(...) \ …
120#define testTrue(...) testTrue_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
123#define testFalse(statement) testTrue( !statement )
126#define testEqual_1(actual,expected) do { \
127 QString actualStr = edbee::test::toQString(actual); \
128 QString expectedStr = edbee::test::toQString(expected); \
129 testEqualImpl( ( actualStr ) == ( expectedStr ), actualStr, expectedStr, #actual, #expected, "", __FILE__, __LINE__ ); \
126#define testEqual_1(actual,expected) do { \ …
132#define testEqual_2(actual,expected, message) do \
133 QString actualStr = edbee::test::toQString(actual); \
134 QString expectedStr = edbee::test::toQString(expected); \
135 testEqualImpl( ( actualStr ) == ( expectedStr ), actualStr, expectedStr, #actual, #expected, (message), __FILE__, __LINE__ ); \
132#define testEqual_2(actual,expected, message) do \ …
139#define testEqual_MACRO_CHOOSER(...) \
140 GET_4TH_ARG(__VA_ARGS__, testEqual_2, testEqual_1, )
139#define testEqual_MACRO_CHOOSER(...) \ …
141#define testEqual(...) testEqual_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
144#define testSkip(msg) testSkipImpl( msg, __FILE__, __LINE__)
173 virtual void testTrueImpl(
bool condition,
const char* statement,
const QString& description,
const char* file,
int line );
176 virtual void testEqualImpl(
bool result,
const QString& actual,
const QString& expected,
177 const char* actualStatement,
const char* expectedStatement,
178 const QString& description,
const char* file,
int line );
180 virtual void testSkipImpl(
const QString& description,
const char* file,
int line );
184 virtual QString currentMethodName();
185 virtual void giveTestResultToEngine(
TestResult* result );
263 virtual int run(
const QString& name );
274 virtual const char*
currentClassName() {
return currentTestRef_->metaObject()->className(); }
279 virtual void giveTestResult(
TestResult* testResult );
286 QList<TestCase*> testRefList_;
291 QString currentMethodName_;
295 QList<TestResult*> testResultList_;
318 child->setObjectName(name);
This is the basic outputhandler. The basic outputhandler simply executes a qDebug with the given info...
Definition test.h:206
virtual void startTestRun(TestEngine *engine)
This method is called if the test run is started.
Definition test.cpp:177
OutputHandler()
The output handler constructor of this test.
Definition test.cpp:164
virtual void startTestMethod(TestEngine *engine)
This method is called if a test method is started.
Definition test.cpp:234
virtual void endTestCase(TestEngine *engine)
This method is called if a testcase is ended.
Definition test.cpp:224
virtual void endTestRun(TestEngine *engine)
This method is called if the test run is completed.
Definition test.cpp:187
virtual void startTestCase(TestEngine *engine)
This method is called if a testcase is started.
Definition test.cpp:216
virtual void endTestMethod(TestEngine *engine)
This method is called if a test method is ended.
Definition test.cpp:244
virtual void testResultAdded(TestEngine *engine, TestResult *testResult)
This method is called if a test result is added.
Definition test.cpp:261
I really really hate the QTestLib output on my Mac. It's a very ugly xwindows console result.
Definition test.h:161
TestCase()
Constructs the testcase.
Definition test.cpp:80
virtual TestEngine * engine()
This method returns the current engine.
Definition test.h:167
virtual void setEngine(TestEngine *engine)
Definition test.h:168
This is the main test engine.
Definition test.h:252
virtual void endRun()
This method should be called when your done with running single test When using runAll you should not...
Definition test.cpp:447
virtual int run(TestCase *object)
This class executes all tests on the given test object (all private Slots)
Definition test.cpp:363
virtual QList< TestResult * > testResultList()
This method returns a list of test results.
Definition test.h:282
virtual int runAll()
This method runs all tests.
Definition test.cpp:345
virtual void setOutputHandler(OutputHandler *handler)
Definition test.h:268
virtual OutputHandler * outputHandler()
Definition test.h:267
virtual QString currentMethodName()
This method returns the current method name.
Definition test.h:277
virtual void startRun()
should be called before the first run when manually running single unit tests When using runAll you s...
Definition test.cpp:439
virtual void addTest(TestCase *object)
this metohd adds a test
Definition test.cpp:337
virtual TestCase * currentTest()
This method returns the current test.
Definition test.h:271
TestEngine()
The test engine constructor.
Definition test.cpp:305
virtual const char * currentClassName()
This method returns the current class name.
Definition test.h:274
virtual bool hasTest(TestCase *object)
this method returns true if the given object is found
Definition test.cpp:324
QSharedPointer< T > child
Definition test.h:314
Test(const QString &name)
Definition test.h:316
This method represents a test result.
Definition test.h:47
TestResult(TestCase *testCase, const QString &methodName, const QString &description, const char *file, int lineNumber)
A single test result.
Definition test.cpp:23
virtual const char * actualStatement()
Definition test.h:76
Status
Definition test.h:49
@ Passed
Definition test.h:50
@ Skipped
Definition test.h:50
@ Failed
Definition test.h:50
virtual const char * statement()
Definition test.h:77
virtual const char * expectedStatement()
Definition test.h:78
virtual Status status()
Definition test.h:82
virtual QString expectedValue()
Definition test.h:80
virtual ~TestResult()
Definition test.h:54
virtual QString description()
Definition test.h:71
virtual QString methodName()
Definition test.h:70
virtual bool compareStatement()
Definition test.h:75
virtual int lineNumber()
Definition test.h:73
virtual QString actualValue()
Definition test.h:79
virtual TestCase * testCae()
Definition test.h:69
virtual const char * fileName()
Definition test.h:72
#define EDBEE_EXPORT
Definition exports.h:15
QString toQString(const T &obj)
Definition test.h:40
TestEngine & engine()
Definition test.h:304
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20