testsoft3 / googletest

Automatically exported from code.google.com/p/googletest
0 stars 0 forks source link

Exceptions on the user code abort the testing process #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 commented 8 years ago
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