Tags:
create new tag
view all tags
OBSOLETE - See TestCasesTutorial for the TWiki testing approach

Introduction

The Wiki:UnitTesting approach ensures that every module has comprehensive unit tests, enabling refactoring of code and generally ensuring that the code is shippable at almost any time, improving quality. SystemTesting and AcceptanceTesting involve similar automated tests at a system level.

Wiki:TestFirstProgramming involves writing tests before you write code, the idea being that there is no point writing any code that is not intended to make a test work. To use an evolutionary analogy, the tests are like environmental pressures, and the code is an organism that needs to evolve to survive (i.e. pass the tests) - so this approach fits well with rapid development techniques such as Wiki:ExtremeProgramming.

CPAN:Test::Harness is the Perl-native unit testing approach - it is best used through CPAN:Test::Simple or CPAN:Test::More, which make it much easier to write test scripts. This is used by CPAN modules as part of make test and is recommended for any Perl module, even if not submitted to CPAN. There is a lot of infrastructure available for rapidly building test suites, smoke testing, etc.

XUnit style unit testing

PerlUnit is an XUnit style unit testing framework for Perl, designed along the lines of JUnit. Its corresponding CPAN module is CPAN:Test::Unit and its development page is at http://perlunit.sf.net/ - some more info is at Wiki:PerlUnit and Wiki:JavaUnit.

CPAN:Test::Class is another XUnit style unit testing framework. It seems to be easier to use than CPAN:Test::Unit, and more 'perlish'. It is (unlike CPAN:Test::Unit) based on CPAN:Test::Builder, which will allow it to easily integrate with many existing Perl tests and testing extensions.

Test::Harness testing

Miscellaneous links

PerlUnit testing

-- RichardDonkin - 09 Jun 2003

There are unit tests for RcsLite and some for Store.pm under tools in CVS. This does not use a standard Perl unit test suite.

-- JohnTalintyre - 10 Jun 2003

I've been working through converting the tests for my plugins to PerlUnit (I already use JUnit for Java). It works well. The best thing is the ability to set up test fixtures that can be re-used and subclassed in other tests. For some of the tests I have set up a "Fake TWiki" which implements Func:: and a little "database builder" so you can generate constrained fixtures (data and pub dirs) without munging an installation.

It can be quite awkward to test comms, though, so I've been looking at HttpUnit to help do this.

-- CrawfordCurrie - 12 Jun 2003

I'm all in favour of unit testing.

I think it would be good, however, if some snapshot of PerlUnit were distributed along with TWiki, if code distributed with TWiki contains unit tests that depend on PerlUnit. Or, equivalently, if TWiki were distributed via something like the FreeBSD ports mechanism (or its equivalent on several Linux flavours) that tracked dependencies.

If you have to go and install something else to run the tests, it's that much harder to run the tests. If the tests are that much harder to run, likelihood is they don't get run. If the tests don't get run, untested bugs creep in.

A case in point. I have spent the better part of today (1) installing PerlUnit, and all of the things it depends on, and (2) figuring out the magic incantation to get TreePlugin's tests running. If there were a standard test framework for twiki, I would expect these to have already been done.

-- AndyGlew - 18 Jun 2003

Should TWiki bundle a test harness for Unit tests?
Do you agree or disagree? Please select one of the radio buttons below and click the button.
I 1 - Strongly disagree   2 - Disagree   3 - am Neutral   4 - Agree   5 - Strongly Agree  


5 RichardDonkin 20 Oct 2004 CPAN:Test::Class fits in better with CPAN tests, and generally seemed a bit easier to use for Perl people. Worth having a look at this too.
5 CrawfordCurrie 20 Oct 2004 I have used CPAN:Test::Unit extensively during plugins development.
5 RafaelAlvarez 19 Oct 2004  
5 WillNorris 19 Oct 2004
5 MartinCleaver 19 Oct 2004

CPAN:Test::Unit seems to be te standard base module, there are others as well though, CPAN:Test

UnitTests are to be a component of DakarRelease. Some exploration of tests scripts are attached to TWikiTestInfrastructure.

-- WillNorris - 19 Oct 2004

Should TWiki bundle a CPAN test harness for Unit tests?
Do you agree or disagree? Please select one of the radio buttons below and click the button.
I 1 - Strongly disagree   2 - Disagree   3 - am Neutral   4 - Agree   5 - Strongly Agree  


3 CrawfordCurrie 20 Oct 2004 I prefer Test::Unit from CPAN, though I'd be happuy with any framework.
5 RafaelAlvarez 19 Oct 2004  
5 WillNorris 19 Oct 2004
5 MartinCleaver 19 Oct 2004

-- MartinCleaver - 19 Oct 2004

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2006-12-06 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.