mnemonic-dev team mailing list archive
-
mnemonic-dev team
-
Mailing list archive
-
Message #00001
Tests
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello, Per and Christoph!
I just wanted to let you know that I have been working on unit tests,
and though there is not yet a test for every function, there are enough
that I'd like to ask for your feedback on a couple of points.
I have been writing test *functions* (as opposed to TestCase classes)
and using nosetests to run them. A couple of issues:
1. "setup" and "tear down" functions don't act on the same name space as
test functions, so I have been using globals inside the setup functions
in order to gain access to variables inside the test functions. This
feels sort of awkward, given all the preaching out there against using
global variables in programs, but it still seems preferable to me over
writing class-based unit tests, indenting all my code yet another four
spaces, and peppering it with "self."s to boot.
Am I missing something about setup and tear down functions in the nose
tests framework? Is there a better way to access variables created in
a setup function? Do you any stylistic opinions on this issue?
2. Lots of the test code is very repetitive, with small changes from one
case to the next. I have used some simple abstractions (for loops,
etc.) when possible, but have avoided writing any functions which
abstract out anything common to several tests, because it seems like we
probably want tests to be able to vary completely independently,
regardless of how similar they start off. Then again, I can see an
argument for going the other way: having abstracted test functions can
help enforce common interfaces across the codebase. What have you guys
done in your previous test writing?
As always, your thoughts are appreciated...
Richard
- --
Richard Lawrence
Research Coordinator
Computational Memory Lab
rwl@xxxxxxxxxxxxxxx
215-746-0407
The PGP signature below is how you can verify that this message was
sent by me, and no one else. To protect your security and privacy,
you may wish to download my key from pgp.mit.edu and verify this
message. Please see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
if you would like to learn more.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkIikwACgkQCWv7yMGrSa9h3QCfWTSbcmPPlMvTupX5aLu4UJyD
Zl4AnAnEdCfJEFiFBj7m9jhTZhKa2S23
=ydae
-----END PGP SIGNATURE-----