in reply to Daemon to test credit-card authorization?
I think it might be a good idea to combine unit testing and mock objects with Roadster001's solution above ( sanitizer -> CC processor). Roadster001 provides a good starting point for breaking down the testing problem into unit tests. Perl has a very rich set of testing modules to get you started on creating both mock objects and test suites.
For the unit testing, you should have at least two test suites. The first would make sure that each and every method of your sanitizer generates the correct sanitized code and handles bad and evil data well. If you are not familiar with taint mode, check the perl docs and consider using it in your application and test suites. The second set of unit tests would make sure that the web requests coming out of your CC processor look exactly as they should (well formed, all fields properly filled in, including the test flag :-), and so on). Again, make sure you have tests that input garbage as well as good data.
Two other hints I find helpful when constructing unit tests are:
As for Perl resources, start by exploring Test::Simple and Test::More if you don't know them already. They provide a great way to compare actual and expected values from your methods. There is also a whole set of objects for simulating interaction with web servers. A search on CPAN for "Test::WWW" might be a good place to start. Putting in "Test Mock" into the CPAN search box should also yield some helpful results.
Best, beth
|
|---|