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(std::ostream
& out
)
22 XmlListener::testStarting(const Testable
* test
)
24 rapidxml::xml_attribute
<> * attr
= 0;
25 rapidxml::xml_node
<> * node
=
26 doc_
.allocate_node(rapidxml::node_element
,
27 test
->isTestSuite() ? "TestSuite" : "Test");
28 node_
->append_node(node
);
30 attr
= doc_
.allocate_attribute("name", test
->name().c_str());
31 node
->append_attribute(attr
);
32 attr
= doc_
.allocate_attribute("type", test
->type().c_str());
33 node
->append_attribute(attr
);
34 attr
= doc_
.allocate_attribute("path", test
->path
.string().c_str());
35 node
->append_attribute(attr
);
41 XmlListener::testFinished(const Testable
* test
)
43 const TestResult
& result(test
->result());
44 rapidxml::xml_attribute
<> * attr
= 0;
46 attr
= doc_
.allocate_attribute("succeed", result
.succeed
? "true" : "false");
47 node_
->append_attribute(attr
);
49 rapidxml::xml_node
<> * child
=
50 doc_
.allocate_node(rapidxml::node_element
, "Details");
51 for (TestResult::details_t::const_iterator it
= result
.details
.begin();
52 it
!= result
.details
.end(); ++it
)
57 attr
= doc_
.allocate_attribute(it
->first
.c_str(),
58 doc_
.allocate_string(ss
.str().c_str()));
59 child
->append_attribute(attr
);
61 node_
->append_node(child
);
63 node_
= node_
->parent();
67 XmlListener::finished()