Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions on the user code abort the testing process #27

Closed
GoogleCodeExporter opened this issue Jul 24, 2015 · 1 comment
Closed

Exceptions on the user code abort the testing process #27

GoogleCodeExporter opened this issue Jul 24, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.
main.cpp
-------- 
bool ThrowAnException()
{
  throw 0;
}
TEST(Test, Exception) 
{ 
  EXPECT_TRUE(ThrowAnException());
}

../main.cpp
-----------
int main(int argc, char **argv) {
  std::cout << "Running main() from gtest_main.cc\n";

  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}


2.   g++ -o main main.cpp ../main.cpp ../lib/libgtest.a -I../include
3. ./main

What is the expected output? What do you see instead?
I expected the same as in Issue 16.

~/tests/test$ ./main
Running main() from gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from Test
[ RUN      ] Test.Exception
terminate called after throwing an instance of 'int'
Aborted

What version of the product are you using? On what operating system?
Just checked out the svn trunk at a Debian GNU/Linux

Please provide any additional information below.
It happened to me while testing googletest in another project but I
simplified to this


Original issue reported on code.google.com by Arkai...@gmail.com on 21 Aug 2008 at 8:08

@GoogleCodeExporter
Copy link
Author

This behavior is by design.  When you run the test under a debugger, the 
exception
will be caught the debugger and you can debug at the throw site.  If you want 
Google
Test to catch the exception, there's the --gtest_catch_exception flag.

Original comment by shiq...@gmail.com on 8 Sep 2008 at 7:18

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant