gzz-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gzz] Jython tests


From: B. Fallenstein
Subject: Re: [Gzz] Jython tests
Date: Sat, 18 May 2002 18:01:13 +0200
User-agent: Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:0.9.9) Gecko/20020414 Debian/0.9.9-6

Tuomas Lukka wrote:
I think I'd prefer just making test scripts like Perl's... They're
a good example of how to make tests simple using character streams.

Test scripts are what I'd like: creating a new test should be as simple as creating a new file and putting a few statements in it.

Each test prints out lines of the form

13
ok 5
not ok 6

where the first number is the number of test cases to expect, then the
next numbers are in a sequence. All other output is ignored (can be used
for debugging).

This, on the other hand, does not sound very useful to me. I certainly don't want to write 'print "ok 5"' statements in my source code-- and change them every time I add a new test case in the middle or something.

How about having a start("Test case description") function? Then we can check for exceptions like JUnit does, and when a testcase fails, we can output the info similarly.

Or maybe, structure the tests as Jython scripts like this:

    -- Set-up code.

    def testThis():
        -- Test code.

    def testThat():
        -- More test code.

    def tearDown():
        -- Tear-down code.

(Forgive my use of Ly-ish metasyntax.) In this scheme, the test engine would load the module and extract the tests by reflection (easy in Python). Then it would call tearDown(), re-load the module for every test, run the test and tearDown() again.

The point is that we'd be using the module namespace for the test fixture variables, meaning each test function would have instant access to them; and by not placing the setUp() code in a method, we'd avoid having to declare the variables in there as 'global'.

In fact, I think we could create a wrapper that encapsulates these as a PyUnit class...

- Benja




reply via email to

[Prev in Thread] Current Thread [Next in Thread]