As of rev 4690, Leo supports "hidden" unit tests. This just may be
the missing piece of Leo's unit testing arsenal.
A hidden unit test is a node that is *not* a section-definition node
and whose body text contains one of the following guards at the start
of a line::
if g.unitTesting
if g.app.unitTesting:
if g.inScript:
if g.app.inScript:
The typical usage pattern is::
class myClass:
...
if g.unitTesting:
x = myClass()
x.test()
For this reason, hidden unit tests could also be called "in place"
unit tests: they appear in the Leo source file, next to the code being
tested.
Notes:
1. [Important]: Any one of the guards above will prevent the unit
testing code from being executing when importing a file. Thus, you
can insert a unit test just after the code you want to test.
2. [Spectacular]: The test tests the latest code *without* you having
to reload Leo. The reason is simple: the code being tests (myClass,
in the example above), is defined by either the unit tests or the
execute-script command.
3. [Happy]: Within leoPy.leo I redefined alt-4 to mean run-all-unit-
tests-locally, which is the most convenient way to run the test I am
working on: running the other tests doesn't matter, and in fact is a
good check.
4. Because hidden unit tests are not marked with @test, Leo always
tells which hidden tests have been found.
A good day for unit testing in Leo.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.