DEV Community

Cover image for Google Test - missing feature
rndthts.dev
rndthts.dev

Posted on • Edited on • Originally published at rndthts.dev

6 4 1

Google Test - missing feature

Test-Driven Development. Red-Green-Refactor.
Let's start. You are working on an awesome project in C++ and for TDD you are using the Google testing framework.

A typical scenario when using TDD:

  • The new behavior is introduced and described by a falling test. We have RED.
  • Logic is implemented, the test is PASSING. We have GREEN.
  • The last step, REFACTOR test and implementation if possible.

After that, we run all the tests and we notice that we have 17 falling tests.
What about re-running only failing tests?
What about re-running the first and last failing tests?

This is something that kept popping up to me.
Google Test does not support anything like this, so I decided to write my solution. Github link

What is it?

Wrapper around Google tests

What it solves?

It allows you to re-run failed tests as well as to filter those failed tests by using numeric tags

How to use it?

  • Set which executable file will be executed:
./gtester.py --exe exe_name
Enter fullscreen mode Exit fullscreen mode
  • Run all tests:
./gtester.py
Enter fullscreen mode Exit fullscreen mode
  • Run just failing tests:
./gtester.py --run_failing
Enter fullscreen mode Exit fullscreen mode
  • Run several failing tests using tags:
./gtester.py --run_failing 1 3
Enter fullscreen mode Exit fullscreen mode

Example

Demo

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay