1
/* Subunit test listener for cppunit (http://cppunit.sourceforge.net).
2
* Copyright (C) 2006 Robert Collins <robertc@robertcollins.net>
4
* Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
5
* license at the users choice. A copy of both licenses are available in the
6
* project source as Apache-2.0 and BSD. You may not use this file except in
7
* compliance with one of these two licences.
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under these licenses is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the license you chose for the specific language governing permissions
13
* and limitations under that license.
16
#include <cppunit/Exception.h>
17
#include <cppunit/Test.h>
18
#include <cppunit/TestFailure.h>
19
#include <cppunit/TextOutputter.h>
22
// Have to be able to import the public interface without config.h.
23
#include "SubunitTestProgressListener.h"
25
#include "subunit/child.h"
32
SubunitTestProgressListener::startTest( Test *test )
34
subunit_test_start(test->getName().c_str());
35
last_test_failed = false;
39
SubunitTestProgressListener::addFailure( const TestFailure &failure )
41
std::ostringstream capture_stream;
42
TextOutputter outputter(NULL, capture_stream);
43
outputter.printFailureLocation(failure.sourceLine());
44
outputter.printFailureDetail(failure.thrownException());
46
if (failure.isError())
47
subunit_test_error(failure.failedTestName().c_str(),
48
capture_stream.str().c_str());
50
subunit_test_fail(failure.failedTestName().c_str(),
51
capture_stream.str().c_str());
52
last_test_failed = true;
56
SubunitTestProgressListener::endTest( Test *test)
58
if (!last_test_failed)
59
subunit_test_pass(test->getName().c_str());