mirror of
https://github.com/pocoproject/poco.git
synced 2025-06-04 05:47:15 +02:00
Add -setup, a command line argument.
This commit is contained in:
parent
8951b90bbe
commit
904b0061eb
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "CppUnit/CppUnit.h"
|
#include "CppUnit/CppUnit.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
@ -29,6 +30,11 @@ public:
|
|||||||
virtual void run(TestResult* result) = 0;
|
virtual void run(TestResult* result) = 0;
|
||||||
virtual int countTestCases() = 0;
|
virtual int countTestCases() = 0;
|
||||||
virtual std::string toString() = 0;
|
virtual std::string toString() = 0;
|
||||||
|
|
||||||
|
void addSetup(const std::vector<std::string>& setup);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> _setup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -57,6 +63,11 @@ inline std::string Test::toString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Test::addSetup(const std::vector<std::string>& setup)
|
||||||
|
{
|
||||||
|
_setup = setup;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ public:
|
|||||||
std::string toString();
|
std::string toString();
|
||||||
|
|
||||||
virtual void setUp();
|
virtual void setUp();
|
||||||
|
virtual void setUp(const std::vector<std::string>& setup);
|
||||||
virtual void tearDown();
|
virtual void tearDown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -202,6 +203,12 @@ inline void TestCase::setUp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// A hook for fixture set up with command line arguments
|
||||||
|
inline void TestCase::setUp(const std::vector<std::string>& setup)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// A hook for fixture tear down
|
// A hook for fixture tear down
|
||||||
inline void TestCase::tearDown()
|
inline void TestCase::tearDown()
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,10 @@ void TestCase::run(TestResult *result)
|
|||||||
{
|
{
|
||||||
result->startTest(this);
|
result->startTest(this);
|
||||||
|
|
||||||
setUp();
|
if (_setup.size() > 0)
|
||||||
|
setUp(_setup);
|
||||||
|
else
|
||||||
|
setUp();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
runTest();
|
runTest();
|
||||||
|
@ -48,6 +48,7 @@ bool TestRunner::run(const std::vector<std::string>& args)
|
|||||||
bool all = false;
|
bool all = false;
|
||||||
bool wait = false;
|
bool wait = false;
|
||||||
bool printed = false;
|
bool printed = false;
|
||||||
|
std::vector<std::string> setup;
|
||||||
|
|
||||||
for (int i = 1; i < args.size(); i++)
|
for (int i = 1; i < args.size(); i++)
|
||||||
{
|
{
|
||||||
@ -71,6 +72,13 @@ bool TestRunner::run(const std::vector<std::string>& args)
|
|||||||
printed = true;
|
printed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (arg == "-setup")
|
||||||
|
{
|
||||||
|
if (i + 1 < args.size())
|
||||||
|
setup.push_back(args[++i]);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!all)
|
if (!all)
|
||||||
{
|
{
|
||||||
@ -89,6 +97,8 @@ bool TestRunner::run(const std::vector<std::string>& args)
|
|||||||
}
|
}
|
||||||
if (testToRun)
|
if (testToRun)
|
||||||
{
|
{
|
||||||
|
if (setup.size() > 0)
|
||||||
|
testToRun->addSetup(setup);
|
||||||
if (!run(testToRun)) success = false;
|
if (!run(testToRun)) success = false;
|
||||||
}
|
}
|
||||||
numberOfTests++;
|
numberOfTests++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user