ENB: Test Driven Study (TDS)

13 views
Skip to first unread message

Edward K. Ream

unread,
Jun 22, 2023, 8:02:16 AM6/22/23
to leo-editor
This Engineering notebook post records Ahas that arose in confronting
#3181. These Ahas may seem small, but there is no such thing as a small Aha!

Aha: Start with the unit test.

Reading the code of g.findUNL put me to sleep. g.findUNL is part of an inherently complex ecosystem.

Improving  test_g_findUnl woke me up. This unit test now contains smaller sub-tests of all the possible UNLs that can arise from error messages. These sub-tests allowed me to focus on more manageable issues.

Aha: The unit test should test all expected error messages.


Each tool (flake8, mypy, pyflakes, pylint, and python) uses a different format for its error message. Tests should cover each.


Similarly, the recently-improved unit test for LM.scanOptions tests all variations of Leo's command-line options, both valid and invalid.


Aha: All error messages (regardless of the tool that generates the test) contain the full absolute path to the erroneous file.


Summary


- Working on a unit test is a great way to get into action.

- TDD works for study as well as development and testing.

  Let's call this approach TDS: test-driven study.

- 100% code coverage is not always enough.

  Tests should cover all options.


Edward

Reply all
Reply to author
Forward
0 new messages