3 #include <rapidxml_print.hpp>
5 #include <moulette/testable.hh>
6 #include "xml-listener.hh"
8 template class rapidxml::xml_node
<>;
9 template class rapidxml::xml_document
<>;
13 XmlListener::XmlListener()
21 XmlListener::testStarting(const Testable
* test
)
23 rapidxml::xml_attribute
<> * attr
= 0;
24 rapidxml::xml_node
<> * node
=
25 doc_
.allocate_node(rapidxml::node_element
,
26 test
->isTestSuite() ? "TestSuite" : "Test");
27 node_
->append_node(node
);
29 attr
= doc_
.allocate_attribute("name", test
->name().c_str());
30 node
->append_attribute(attr
);
31 attr
= doc_
.allocate_attribute("type", test
->type().c_str());
32 node
->append_attribute(attr
);
33 attr
= doc_
.allocate_attribute("path", test
->path
.string().c_str());
34 node
->append_attribute(attr
);
40 XmlListener::testFinished(const Testable
* test
)
42 const TestResult
& result(test
->result());
43 rapidxml::xml_attribute
<> * attr
= 0;
45 attr
= doc_
.allocate_attribute("succeed", result
.succeed
? "true" : "false");
46 node_
->append_attribute(attr
);
48 rapidxml::xml_node
<> * child
=
49 doc_
.allocate_node(rapidxml::node_element
, "Details");
50 for (TestResult::details_t::const_iterator it
= result
.details
.begin();
51 it
!= result
.details
.end(); ++it
)
56 attr
= doc_
.allocate_attribute(it
->first
.c_str(),
57 doc_
.allocate_string(ss
.str().c_str()));
58 child
->append_attribute(attr
);
60 node_
->append_node(child
);
62 node_
= node_
->parent();
66 XmlListener::finished()