blob: 37f296b7e9fc57a0158dd15dc0ba15127cb8415b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#pragma once
#include "External/UnitTest++/src/TestReporter.h"
#include "External/UnitTest++/src/TestDetails.h"
/// Unit test reporter that logs to console output.
class ConsoleTestReporter : public UnitTest::TestReporter
{
public:
ConsoleTestReporter ();
virtual ~ConsoleTestReporter ();
virtual void ReportTestStart (UnitTest::TestDetails const& test);
virtual void ReportFailure (UnitTest::TestDetails const& test, char const* failure);
virtual void ReportTestFinish (UnitTest::TestDetails const& test, float secondsElapsed);
virtual void ReportSummary (int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
void ReportMessage (LogType type, std::string message);
void ExpectLogMessage (LogType type, const char* logFragment);
void SetShowOnlySummary (bool value) { m_ShowOnlySummary = value; }
void SetTestNameColumnIndex (int value) { m_TestNameColumnIndex = value; }
void SetResultColumnIndex (int value) { m_ResultColumnIndex = value; }
bool IsCurrentlyRunningTest () const { return m_IsCurrentlyRunningTest; }
static ConsoleTestReporter* GetInstance();
private:
bool m_IsCurrentlyRunningTest;
bool m_ShowOnlySummary;
int m_TestNameColumnIndex;
int m_ResultColumnIndex;
struct Failure
{
std::string text;
std::string fileName;
int lineNumber;
};
typedef std::pair<LogType, std::string> LogMessage;
std::vector<UnitTest::TestDetails> m_FailedTests;
bool m_CurrentTestIsFailure;
UnitTest::TestDetails m_CurrentTest;
std::vector<Failure> m_CurrentTestFailures;
std::vector<LogMessage> m_UnexpectedLogMessagesForCurrentTest;
std::vector<LogMessage> m_ExpectedLogMessagesForCurrentTest;
void MarkCurrentTestAsFailure ()
{
if (m_CurrentTestIsFailure)
return;
m_CurrentTestIsFailure = true;
m_FailedTests.push_back (m_CurrentTest);
}
};
|