doctest icon indicating copy to clipboard operation
doctest copied to clipboard

Feature request: Test focusing decoration

Open jeaye opened this issue 3 years ago • 1 comments

Description

Hi! Thanks for making doctest. :)

I'd like to request a feature to allow developers to focus on specific tests. In doctest, the way that would work is probably using a decorator such as doctest::focus(bool = true). The purpose of focusing on tests is to have doctest only run focused tests if any of them are focused. Otherwise, run all tests as normal.

With my setup, I use doctest with entr to automatically re-compile and run the test suite whenever I save changes. This is a great setup, but often times I'm adding logging to figure out what's wrong with a specific test case and I need to deal with all the extra logs from the other test cases, too. I could comment them out, but they're split between dozens of files. With this proposed feature, I can just decorate the test(s) I want to focus on and then none of the others will run!

I know that doctest has test selectors as command-line arguments, but I'm in the code, running the tests; the tests run automatically. If I can focus on tests from the code, there's no need to switch back and forth between the editor and a terminal to restart the test runner. Not to mention having to type out the selector for the tests to run on the cmd line, especially if I want to focus on multiple, can be cumbersome.

In other languages, this is a common and excellent feature. For example, in Clojure: https://github.com/jakemcc/test-refresh#built-in-test-narrowing-test-selector

I'm really hoping you're open to this. Thanks so much for your time.

jeaye avatar Aug 23 '22 06:08 jeaye

@jeaye I think this is a good feature. If you can implement that decorator and make a PR I'm sure it will be appreciated by others using your workflow as well.

cdeln avatar Aug 21 '24 18:08 cdeln