I have some Selenium Webdriver GUI tests that run on every check-in in our Trac/Bitten build environment. For various silly reasons, these are fragile and re-running the failed test always works (unless it doesn't, and then I have an actually failing test).
How do I re-run these failed tests? The GUI tests take 10-15 minutes to run, so re-running all of them is a pain.
Here is the build step:
<step id="guitest" description="Run gui tests">
<sh:exec executable="gui_tests.sh" />
</step>
and gui_tests.sh
# Setup environment stuff deleted
nosetests python/*Tests.py -v
We are working to make the GUI tests more robust, but my understanding is that this is life with GUI tests.
EDIT June 2021: Surprised this is still getting votes. If at all possible, consider using ptyest with the --last-failed
option.
It turns out this is trivial with nose. First run the command and include the --with-id
flag.
# Environment stuff deleted
nosetests python/*Tests.py -v --with-id
nosetests python/*Tests.py -v --failed
If, say, four tests fail, running with the --failed
flag will run only those four tests. If you then correct three, running with --failed
will run only the remaining failed test.
Running --with-id
again resets the tracking of failed tests and runs all the found tests.
I searched quite a bit for this before I wandered into writing my own plugin. When I was researching how to register my plug-in I found some code that happened to be the testid plugin provided by nose, which provides the functionality above. Sheesh. I am documenting this here, hoping to save someone else some time.
Of course, now that I know about it, it's so obviously found with:
nosetests --help
I scanned the docs initially, but didn't think it would be so easy, so I did so half-heartedly.