On Monday, August 23, 2021 at 12:58:38 PM UTC-5 Edward K. Ream wrote:

> `@test` and `@suite` nodes rank as one of the worst ideas I have ever 
had. 

I have been converting tests for the last several days. Completing this 
project will take about a week. To repeat, the new unit tests will be part 
of Leo 6.5, not 6.4.

I am astounded at how easy the new (proper) unit tests are. Unlike with 
@test and @suite nodes, there is no need to ensure that tests don't change 
unitTest.leo. Avoiding teardown issues drastically simplifies most tests.  
unittest.assertEqual typically suffices to show test failures--no need for 
bespoke tracing code.

Each unit test runs in a pristine (almost) environment. I say "almost" 
because setUpClass creates a single instance of Leo (the LeoApp class, 
shared by all tests of a particular test file.

Each unit test gets a pristine new outline. Some subclasses of LeoUnitTest 
create more complex test outlines for each test. Just a few lines of code 
in a test suffice to create any subtrees needed by a particular test.

Finally, there is no need to reload Leo to run tests. Running `python -m 
unittest` always uses the very latest code. Avoiding reload issues is a 
huge advantage. No need for "prefix" code or explicit calls to 
importlib.reload!!!

*Summary*

I created @test and @suite to make Leo outlines (and Leo itself!) available 
to all unit tests. But the LeoUnitTest class shows how easy is it to 
recreate Leo's *total* environment from proper unit tests.

Tests in @test and @suite nodes are much *harder* to write and maintain 
than proper unit tests. The work I am doing will be the foundation of a new 
era in unit testing for Leo.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/2aa5b59d-6ca7-4891-82a0-107b00668008n%40googlegroups.com.

Reply via email to