}
TestCase::~TestCase() {
+ // TestCase should not be deleted until is safeToClear()
reset(true); // hard reset
std::vector<TestStep*>::const_iterator it;
for (it = a_steps.begin(); it != a_steps.end(); it++) delete (*it);
}
+
const char* TestCase::asText(const State::_v state)
throw() {
static const char* text [] = { "Initialized", "InProgress", "Failed", "Success" };
return true;
}
+bool TestCase::safeToClear() {
+
+ // Check if any step is running (command steps):
+ std::vector<TestStep*>::const_iterator it;
+ for (it = a_steps.begin(); it != a_steps.end(); it++) {
+ if ((*it)->getType() == TestStep::Type::Cmd) {
+ const TestStepCmd *tscmd = static_cast<const TestStepCmd*>(*it);
+ if(tscmd->threadRunning())
+ return false;
+ }
+ }
+
+ return true;
+}
+
void TestCase::assertInitialized() const throw(anna::RuntimeException) {
if (isFinished())
throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu (%s) has finished. You must reset it to append new steps (or do it during execution, which is also allowed).", a_id, a_description.c_str()), ANNA_FILE_LOCATION);