Python on rndthts.dev https://rndthts.dev/tags/python/ Recent content in Python on rndthts.dev Hugo -- gohugo.io en-us Sun, 03 Oct 2021 20:37:24 +0200 Google Test - Missing Feature https://rndthts.dev/posts/google-test-missing-feature/ Sun, 03 Oct 2021 20:37:24 +0200 https://rndthts.dev/posts/google-test-missing-feature/ <p><strong>Test-Driven Development</strong>. <strong>Red-Green-Refactor</strong>. Let&rsquo;s start. You are working on an awesome project in C++ and for TDD you are using the Google testing framework.</p> <p>A typical scenario when using TDD:</p> <ul> <li>The new behavior is introduced and described by a falling test. <strong>We have RED</strong>.</li> <li>Logic is implemented, the test is PASSING. <strong>We have GREEN</strong>.</li> <li>The last step, <strong>REFACTOR</strong> test and implementation if possible.</li> </ul> <p>After that, we run all the tests and we notice that <strong>we have 17 falling tests</strong>.<br> What about re-running only failing tests? <br> What about re-running the first and last failing tests?</p> <p>This is something that kept popping up to me. Google Test does not support anything like this, so I decided to write my solution. <a href="https://github.com/elvisoric/gtester">Github link</a></p> <h2 id="what-is-it">What is it?</h2> <p>Wrapper around Google tests</p> <h2 id="what-it-solves">What it solves?</h2> <p>It allows you to re-run failed tests as well as to filter those failed tests by using numeric tags</p> <h3 id="how-to-use-it">How to use it?</h3> <ul> <li>Set which executable file will be executed:</li> </ul> <pre tabindex="0"><code>./gtester.py --exe exe_name </code></pre><ul> <li>Run all tests:</li> </ul> <pre tabindex="0"><code>./gtester.py </code></pre><ul> <li>Run just failing tests:</li> </ul> <pre tabindex="0"><code>./gtester.py --run_failing </code></pre><ul> <li>Run several failing tests using tags:</li> </ul> <pre tabindex="0"><code>./gtester.py --run_failing 1 3 </code></pre><h2 id="example">Example</h2> <p><img src="https://rndthts.dev/images/gtester_demo.gif" alt="Demo"></p>