--
Zhanyong
TEST_F(MyTest, Test1)
try
{
//whatever
}
catch(...)
{
FAIL() << "exception" << std::endl;
}
where you could of course have multiple catch blocks depending on the type of
exception with more informative reporting.
If you want to reduce the boilerplate, define macros so that this becomes
TEST_F(MyTest, Test1)
BEGIN_TEST
{
//whatever
}
END_TEST
On Tue, Dec 28, 2010 at 12:57 PM, Joey Oravec <joeyo...@gmail.com> wrote:
> Steve,
>
> You have a useful boilerplate there, but it catches exceptions inside
> the fixture's TestBody() and Michael described an exception that gets thrown
> from the fixture's constructor. I don't expect it would catch what he
> described.
>
> I checked SVN head and Test::Run() uses a function to call SetUp(),
> TestBody(), and TearDown() within a try-catch block if exception catching is
> enabled. Somebody smarter than me would have to answer what happens when an
> exception is thrown from the fixture's constructor. I don't know what would
> happen or where the exception would get caught.
You are right that gtest SVN head doesn't handle exceptions thrown in
a test fixture ctor yet. I've re-opened issue 44 to track this and
some related cases. Thanks,
--
Zhanyong
Vlad just pointed out to me that the SVN head actually already handles
exceptions thrown in test fixture ctor/dtor and several other places
as well. I verified it by looking at the code and the unit tests. So
I closed issue 44. Sorry for the noise.
--
Zhanyong