DEV Community

Kelly Stannard
Kelly Stannard

Posted on

1

Find that flaky test

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.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more