summaryrefslogtreecommitdiffstats
path: root/googletest/include
diff options
context:
space:
mode:
authorAlexey Sokolov <sokolov@google.com>2018-02-03 23:36:19 (GMT)
committerAlexey Sokolov <sokolov@google.com>2018-02-08 01:15:42 (GMT)
commit092d0885332316ca679ac77e0f8fe1f5c368fb4f (patch)
tree8a9cae8146f8c4f93c6a59de375229034e6d8e5d /googletest/include
parentea31cb15f0c2ab9f5f5b18e82311eb522989d747 (diff)
downloadgoogletest-092d0885332316ca679ac77e0f8fe1f5c368fb4f.zip
googletest-092d0885332316ca679ac77e0f8fe1f5c368fb4f.tar.gz
googletest-092d0885332316ca679ac77e0f8fe1f5c368fb4f.tar.bz2
Add ability to throw from ASSERT
while not losing benefits of EXPECT, and not killing the whole test, as with --gtest_throw_on_failure. 183822976
Diffstat (limited to 'googletest/include')
-rw-r--r--googletest/include/gtest/gtest.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 01994e6..26e787d 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -138,7 +138,7 @@ GTEST_DECLARE_int32_(stack_trace_depth);
// When this flag is specified, a failed assertion will throw an
// exception if exceptions are enabled, or exit the program with a
-// non-zero code otherwise.
+// non-zero code otherwise. For use with an external test framework.
GTEST_DECLARE_bool_(throw_on_failure);
// When this flag is set with a "host:port" string, on supported
@@ -1004,6 +1004,18 @@ class Environment {
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
};
+#if GTEST_HAS_EXCEPTIONS
+
+// Exception which can be thrown from TestEventListener::OnTestPartResult.
+class GTEST_API_ AssertionException
+ : public internal::GoogleTestFailureException {
+ public:
+ explicit AssertionException(const TestPartResult& result)
+ : GoogleTestFailureException(result) {}
+};
+
+#endif // GTEST_HAS_EXCEPTIONS
+
// The interface for tracing execution of tests. The methods are organized in
// the order the corresponding events are fired.
class TestEventListener {
@@ -1032,6 +1044,8 @@ class TestEventListener {
virtual void OnTestStart(const TestInfo& test_info) = 0;
// Fired after a failed assertion or a SUCCEED() invocation.
+ // If you want to throw an exception from this function to skip to the next
+ // TEST, it must be AssertionException defined above, or inherited from it.
virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
// Fired after the test ends.