Find that flaky test
KW Stannard

KW Stannard @kwstannard

About: Developer. Design pattern enthusiast. Tilting at Agile practices.

Joined:
Sep 9, 2019

Find that flaky test

Publish Date: Oct 22 '20
1 0

A simple way to find that flaky test while you go do other things. This will run your tests over and over until it fails, at which point it will print the number of times the tests passed and open the output from the failing test run.

while rspec path/to/test_spec.rb > /tmp/last_run; do printf .; done | wc -c; less /tmp/last_run

rspec path/to/test_spec.rb > /tmp/last_run runs the tests and writes output to a tmp file.

while will loop if the test run passes and stop looping on a failure.

do printf . prints a single '.' on a test pass.

| wc -c reads the string of '.' and counts them.

less /tmp/last_run displays the last_run, which will be the failure.

Comments 0 total

    Add comment