I wanted to write some tests for a patch I'm writing, and a necessary precursor would seem to be a working set of existing tests. However the tests in tools/test do not compile under the latest alpha, and do not work with the latest beta.
With the alpha, I'm trying to run the tests using
perl unittest
in the source tree (not an installed wiki). I get
syntax error at ../../lib/TWiki.pm line 721, near "} else"
syntax error at ../../lib/TWiki.pm line 735, near "}"
Compilation failed in require at TestStore.pm line 8.
BEGIN failed--compilation aborted at TestStore.pm line 8.
Compilation failed in require at unittest line 3.
BEGIN failed--compilation aborted at unittest line 3.
Running in an installed beta20040119 wiki I get:
Can't locate object method "writeTypes" via package "TWiki::Meta" at TestMeta.pm line 67.
--
CrawfordCurrie - 05 Mar 2004
I'm afraid this just highlights the fact that these unit tests never got widespread acceptance. There been lots of disucssion of unit tests and more testing, but little willingness to do it.
I've been running the
RcsListUnitTests recently and these worked okay. There's behind a OO interface that hasn't changed.
It would be great if we had a more broadly accepted set of unit test that are run by all of the
CoreTeam and by developers submitting patches and other code.
I'll see if I can fix these over the weekend.
--
JohnTalintyre - 05 Mar 2004
John, I'm quite happy to fix them if I can get some idea of why the first compile failure occurs!
Correct me if I'm wrong, but the tests (certainly the Store and Meta tests) seem to assume the pre-existence of a TWiki installation - what I would refer to as a "test fixture". One thing that isn't clear to me is the status of this fixture. Are the tests assumed to be run in a fresh twiki? Is there any code that builds this fixture? For the most basic tests, such as Store, there really should be no need for a full twiki fixture (unless global variables are in evidence of course) but for some of the higher-up modules it may be required, so a strategy for managing it is needed.
FYI I built fixtures for the Plugins tests using an approach of "stubbing" the interfaces used by the code. Since they mostly work entirely withing Func that wasn't too hard, but I also built partial stubs for Store and Meta. These stubs mimic TWiki functionality in a highly constrained and testable way. I started trying to reverse-engineer fixtures for Store and Meta, but stalled when I couldn't work out how the interfaces were supposed to work.
--
CrawfordCurrie - 05 Mar 2004
laughing
Actually, your first problem has nothing to do with your tests at all. It's a typo introduced during one of
RichardDonkin's CVS commits made on the fourth. It's fixed in current CVS.
--
WalterMundt - 05 Mar 2004
Ooops, sorry about that - it's always the simple changes that trip you up...
--
RichardDonkin - 05 Mar 2004
They work now.
--
CrawfordCurrie - 13 Feb 2005