Scaling Personal Growth

Growth is something perhaps we all can relate to wanting, either for being a better person tomorrow or for the sake of satisfying some end. If you can grow enough you can get what you want faster…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Unit Tests Can Crash

Test-Driven Development for Embedded C — Pragmatic Programmers (22 / 173)

👈 CppUTest: A C++ Unit Test Harness | TOC | The Four-Phase Test Pattern 👉

One other possible outcome during a test run is a crash. Generally speaking, C is not a safe language. The code can go off into the weeds, never to return. sprintf is a dangerous function. If you pass it an output buffer that is too small, it will corrupt memory. This error might crash the system now. It might crash later. The behavior is undefined. Consequently, a test run may silently exit with an OK, silently exit early showing no errors, or crash with a bang.

When you have a silent failing or crashing test, let the test harness help you confirm what is wrong. Sometimes a production code change will cause a previously passing test to fail, or even crash. So, before chasing the crash, make sure you know which test is failing.

Because the test harness is normally quiet except for test failures, when a test crashes, you probably won’t get any useful output. Both Unity and CppUTest have a command-line option for running the test in verbose mode (-v). With -v, each TEST announces itself before running. Conveniently, the last TEST mentioned is the one that crashed.

You can also filter tests by test group (-g testgroup) and test case (-n testname). This lets you get very precise about which test cases are running. These are very helpful for chasing down crashes.

👈 CppUTest: A C++ Unit Test Harness | TOC | The Four-Phase Test Pattern 👉

Add a comment

Related posts:

Our Fears

We reveal our motivation with what we choose to share. Observe how we start and end our discussions. We tell on ourselves, seeing it easily in others but missing it in our own actions. We show our…

Back Up Your Content

You work hard to write your content and it would be a genuine shame if you lost it. I can’t stress enough how important it is to back up your blog’s content. Your hosting company may offer you backup…

Activity 2 Empathy Map

Brainstorm and record a particular stakeholder’s responsibilities, thoughts, and feelings to help the team develop a greater sense of empathy with stakeholders’ goals.