blitzdg
an open-source project aiming to implement parallel discontinuous Galerkin (dg) solvers for common partial differential equations systems using blitz++ for array and tensor manipulations and MPI for distributed parallelism.
xunitoutput.h
1 
2 // Copyright Bertrand Cachet 2012
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef IGLOO_XUNITOUTPUT_H
8 #define IGLOO_XUNITOUTPUT_H
9 
10 #include <typeinfo>
11 
12 #include <igloo/core/outputters/xmlwriter.h>
13 
14 namespace igloo {
16  {
17  public:
18 
19  XUnitResultsOutput(std::ostream& outstream = std::cout)
20  : TestResultsOutput(outstream)
21  {
22  }
23 
24  void PrintResult(const TestResults& results) const
25  {
26  XmlWriter xw(this->output);
27  XmlElement testsuite("testsuite", xw);
28 
29  testsuite.attr("name", "Igloo");
30  testsuite.attr("tests", results.NumberOfTestsRun());
31  testsuite.attr("errors", 0);
32  testsuite.attr("failures", results.NumberOfFailedTests());
33  for (TestResults::FailedTestsType::const_iterator it = results.FailedTests().begin();
34  it != results.FailedTests().end();
35  it++)
36  {
37  const FailedTestResult& result = *it;
38  XmlElement testcase("testcase", xw);
39  testcase.attr("classname", result.GetContextName());
40  testcase.attr("name", result.GetSpecName());
41  testcase.attr("time", 0);
42  XmlElement failure("failure", xw);
43  std::ostringstream builder;
44  if(result.HasLineNumber() && result.HasFilename())
45  {
46  builder << result.Filename() << "("
47  << result.LineNumber() << "): "
48  << "assertion failed error: ";
49  }
50 
51  builder << result.GetErrorMessage();
52  failure.attr("message", builder.str());
53  }
54 
55  for (TestResults::SucceededTestsType::const_iterator it = results.SucceededTests().begin();
56  it != results.SucceededTests().end();
57  it++)
58  {
59  const SucceededTestResult& result = *it;
60  XmlElement testcase("testcase", xw);
61  testcase.attr("classname", result.GetContextName());
62  testcase.attr("name", result.GetSpecName());
63  testcase.attr("time", 0);
64  }
65  }
66  };
67 }
68 #endif
Definition: testresult.h:52
Definition: testresultsoutput.h:12
Definition: xmlwriter.h:37
Definition: xunitoutput.h:15
Definition: context.h:13
Definition: xmlwriter.h:68
Definition: testresult.h:12
Definition: testresults.h:12