failure_listener.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <gtest/gtest.h>
10 
11 namespace illumina{ namespace interop { namespace unittest
12 {
13 
15  class failure_listener : public ::testing::TestEventListener
16  {
17  protected:
19  ::testing::TestEventListener *m_event_listener;
20 
21  public:
27  explicit failure_listener(::testing::TestEventListener *event_listener,
28  const bool regression) : m_event_listener(event_listener), m_regression(regression)
29  {
30  }
31 
32  public:
35  {
36  delete m_event_listener;
37  }
42  virtual void OnTestProgramStart(const ::testing::UnitTest &unit_test)
43  {
44  m_event_listener->OnTestProgramStart(unit_test);
45  }
51  virtual void OnTestIterationStart(const ::testing::UnitTest &unit_test, int iteration)
52  {
53  m_event_listener->OnTestIterationStart(unit_test, iteration);
54  }
56  virtual void OnEnvironmentsSetUpStart(const ::testing::UnitTest &/*unit_test*/)
57  {
58  }
59 
61  virtual void OnEnvironmentsSetUpEnd(const ::testing::UnitTest &/*unit_test*/)
62  {
63  }
64 
69  virtual void OnTestCaseStart(const ::testing::TestCase &test_case)
70  {
71  if(m_regression)
72  {
73  m_event_listener->OnTestCaseStart(test_case);
74  }
75  }
76 
78  virtual void OnTestStart(const ::testing::TestInfo &/*test_info*/)
79  {
80  }
81 
86  virtual void OnTestPartResult(const ::testing::TestPartResult &result)
87  {
88  m_event_listener->OnTestPartResult(result);
89  }
94  virtual void OnTestEnd(const ::testing::TestInfo &test_info)
95  {
96  if (test_info.result()->Failed())
97  {
98  m_event_listener->OnTestEnd(test_info);
99  }
100  }
101 
106  virtual void OnTestCaseEnd(const ::testing::TestCase &test_case)
107  {
108  if(m_regression)
109  {
110  m_event_listener->OnTestCaseEnd(test_case);
111  }
112  }
113 
115  virtual void OnEnvironmentsTearDownStart(const ::testing::UnitTest &/*unit_test*/)
116  {
117  }
119  virtual void OnEnvironmentsTearDownEnd(const ::testing::UnitTest &/*unit_test*/)
120  {
121 
122  }
128  virtual void OnTestIterationEnd(const ::testing::UnitTest &unit_test, int iteration)
129  {
130  m_event_listener->OnTestIterationEnd(unit_test, iteration);
131  }
132 
137  virtual void OnTestProgramEnd(const ::testing::UnitTest &unit_test)
138  {
139  m_event_listener->OnTestProgramEnd(unit_test);
140  }
141  private:
142  bool m_regression;
143  };
144 }}}
145 
146 
virtual void OnEnvironmentsTearDownEnd(const ::testing::UnitTest &)
Definition: failure_listener.h:119
Definition: enum_description.h:15
virtual void OnTestEnd(const ::testing::TestInfo &test_info)
Definition: failure_listener.h:94
virtual void OnTestIterationStart(const ::testing::UnitTest &unit_test, int iteration)
Definition: failure_listener.h:51
failure_listener(::testing::TestEventListener *event_listener, const bool regression)
Definition: failure_listener.h:27
virtual void OnTestCaseStart(const ::testing::TestCase &test_case)
Definition: failure_listener.h:69
virtual void OnTestPartResult(const ::testing::TestPartResult &result)
Definition: failure_listener.h:86
virtual void OnTestIterationEnd(const ::testing::UnitTest &unit_test, int iteration)
Definition: failure_listener.h:128
virtual void OnEnvironmentsTearDownStart(const ::testing::UnitTest &)
Definition: failure_listener.h:115
virtual void OnTestStart(const ::testing::TestInfo &)
Definition: failure_listener.h:78
virtual void OnTestProgramStart(const ::testing::UnitTest &unit_test)
Definition: failure_listener.h:42
::testing::TestEventListener * m_event_listener
Definition: failure_listener.h:19
virtual void OnEnvironmentsSetUpStart(const ::testing::UnitTest &)
Definition: failure_listener.h:56
virtual void OnTestCaseEnd(const ::testing::TestCase &test_case)
Definition: failure_listener.h:106
Definition: failure_listener.h:15
virtual void OnEnvironmentsSetUpEnd(const ::testing::UnitTest &)
Definition: failure_listener.h:61
virtual ~failure_listener()
Definition: failure_listener.h:34
virtual void OnTestProgramEnd(const ::testing::UnitTest &unit_test)
Definition: failure_listener.h:137