@@ -132,6 +132,51 @@ namespace lizardbyte::common::testing {
132132 */
133133 void SetUp () override ;
134134 };
135+
136+ /* *
137+ * @brief GoogleTest event listener that buffers test log output until a test fails.
138+ */
139+ class BufferedTestEventListener : public ::testing::EmptyTestEventListener {
140+ public:
141+ /* *
142+ * @brief Handle the start of a test.
143+ * @param test_info GoogleTest test information.
144+ */
145+ void OnTestStart (const ::testing::TestInfo &test_info) override ;
146+
147+ /* *
148+ * @brief Handle a test assertion result.
149+ * @param test_part_result GoogleTest assertion result.
150+ */
151+ void OnTestPartResult (const ::testing::TestPartResult &test_part_result) override ;
152+
153+ /* *
154+ * @brief Handle the end of a test.
155+ * @param test_info GoogleTest test information.
156+ */
157+ void OnTestEnd (const ::testing::TestInfo &test_info) override ;
158+
159+ protected:
160+ /* *
161+ * @brief Add a test event line to the buffer.
162+ * @param message Message to buffer.
163+ */
164+ virtual void logTestEvent (const std::string &message);
165+
166+ /* *
167+ * @brief Get buffered test output.
168+ * @return Buffered output.
169+ */
170+ [[nodiscard]] virtual std::string bufferedTestOutput () const ;
171+
172+ /* *
173+ * @brief Clear buffered test output.
174+ */
175+ virtual void clearBufferedTestOutput ();
176+
177+ private:
178+ std::stringstream event_buffer_; /* *< Stores event log output while tests run. */
179+ };
135180} // namespace lizardbyte::common::testing
136181
137182#if !defined(LIZARDBYTE_COMMON_TESTING_NO_GLOBAL_ALIASES)
@@ -154,6 +199,11 @@ using MacOSTest = ::lizardbyte::common::testing::MacOSTest;
154199 * @brief Global compatibility alias for the shared Windows-only test fixture.
155200 */
156201using WindowsTest = ::lizardbyte::common::testing::WindowsTest;
202+
203+ /* *
204+ * @brief Global compatibility alias for the shared buffered test event listener.
205+ */
206+ using BufferedTestEventListener = ::lizardbyte::common::testing::BufferedTestEventListener;
157207#endif
158208
159209#if !defined(LIZARDBYTE_COMMON_TESTING_KEEP_GTEST_TEST)
0 commit comments