What frameworks and tools would you recommend for unit-testing and mock objects in Perl?
I have an existing Perl application, that mainly does database access, reading and writing files. The application is basically a batch job type of application, it reads in bunch of stuff from files and database and writes a bunch of new files and some stuff to database.
The application currently does not have any unit-test, but I’d like refactor application to have good unit tests.
What frameworks and tools would you recommend for unit-testing and mocking objects? For example something similar to Hamcrest and JMock of Java?
Also, are there any good BDD (Behaviour Driven Development) based testing frameworks for Perl?
In terms of test frameworks, I like to use Test::Class, which lets you set up nice unit test hierarchies in a manner similar to JUnit. The linked documentation gives a pretty good overview, though if you’re not already familiar with Perl testing conventions, check out the documentation for Test::Simple and TAP, which is the standard output format for Perl tests.
For mocking, there is Test::Mock::Class, which is useful for setting up mock classes for libraries outside your direct control, like CPAN modules that your application relies on.
There is also the excellent Test::MockDBI which provides special facilities for mocking your database stuff.