Unit testing: cleaning up after a test fails

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Unit testing: cleaning up after a test fails

Postby RobMeades » Thu Feb 14, 2019 5:09 pm

I have a set of unit test cases building and running successfully.

In general, each of my tests has to lock a resource, use that resource and then unlock the resource. My problem is that, if one of the TEST_ASSERT() checks that I'm making fails while the test is in the "using resource" portion, the test ends and the next one is started, entirely skipping the unlock code, hence everything falls over in an untidy heap.

Usually with Unity I believe this would be fixed in the tearDown() function that is called at the end of every test but in this case unity_platform.c has that function and I can't see any hooks that I can grab.

Before I start hacking a solution to my problem, is there a proper solution somewhere that I've missed?

Who is online

Users browsing this forum: AdsBot [Google] and 128 guests