runner.h
Go to the documentation of this file.
/*
* kunittest.h
*
* Copyright (C) 2004 Zack Rusin <zack@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KUNITTEST_RUNNER_H
#define KUNITTEST_RUNNER_H
#include <iostream>
using namespace std;
#include <qobject.h>
#include <qasciidict.h>
#include <qstring.h>
#include <kdelibs_export.h>
#include "tester.h"
class QSocketNotifier;
namespace KUnitTest
{
#define KUNITTEST_SUITE(suite)\
static const QString s_kunittest_suite = suite;
#define KUNITTEST_REGISTER_TESTER( tester )\
static TesterAutoregister tester##Autoregister( QString(s_kunittest_suite + QString("::") + QString::fromLocal8Bit(#tester)).local8Bit() , new tester ())
#define KUNITTEST_REGISTER_NAMEDTESTER( name, tester )\
static TesterAutoregister tester##Autoregister( QString(s_kunittest_suite + QString("::") + QString::fromLocal8Bit(name)).local8Bit() , new tester ())
typedef QAsciiDict<Tester> RegistryType;
typedef QAsciiDictIterator<Tester> RegistryIteratorType;
class KUNITTEST_EXPORT Runner : public QObject
{
Q_OBJECT
public:
static void registerTester(const char *name, Tester *test);
RegistryType &registry();
static Runner *self();
int numberOfTestCases();
static void loadModules(const QString &folder, const QString &query);
static void setDebugCapturingEnabled(bool enabled);
private:
RegistryType m_registry;
static Runner *s_self;
static bool s_debugCapturingEnabled;
protected:
Runner();
public:
int numberOfTests() const;
int numberOfPassedTests() const;
int numberOfFailedTests() const;
int numberOfExpectedFailures() const;
int numberOfSkippedTests() const;
public slots:
int runTests();
void runTest(const char *name);
void runMatchingTests(const QString &prefix);
void reset();
signals:
void finished(const char *name, Tester *test);
void invoke();
private:
void registerTests();
private:
int globalSteps;
int globalTests;
int globalPasses;
int globalFails;
int globalXFails;
int globalXPasses;
int globalSkipped;
};
class TesterAutoregister
{
public:
TesterAutoregister(const char *name, Tester *test)
{
if ( test->name() == 0L ) test->setName(name);
Runner::registerTester(name, test);
}
};
}
#endif
KUnitTest::Tester
Definition: tester.h:522
KUnitTest::TesterAutoregister::TesterAutoregister
TesterAutoregister(const char *name, Tester *test)
Definition: runner.h:210
tester.h
KUnitTest::TesterAutoregister
Definition: runner.h:204
KUnitTest::Runner
Definition: runner.h:97
KUnitTest::RegistryType
QAsciiDict< Tester > RegistryType
Definition: runner.h:75
KUnitTest::RegistryIteratorType
QAsciiDictIterator< Tester > RegistryIteratorType
Definition: runner.h:78

KDE Home | KDE Accessibility Home | Description of Access Keys