
A few weeks ago, I wrote about how there were now built-in ways to clean up WebGUI objects created for testing. That code has continued to grow and evolve.
storagesToDelete() now accepts storageIds, as well as storage objects.
usersToDelete() was added, so now you can register user objects that should be removed at the end of tests. The clean up handler will let you register the built-in Admin and Visitor users, but will silently skip deleting them, since that would really break your site.
That idea turned out to be so handy that the groupsToDelete() subroutine now screens for default groups.
If you set the environment variable WEBGUI_TEST_DEBUG=1, you will get a report of the number of sessions, user sessions, users and groups at the end of a test. This can help track down leaky tests. This needs to be extended to check for storage locations and version tags, as well.
While going through and updating all the tests to use *ToDelete(), I realized that almost every WebGUI object has a delete method, which leads me to believe that there should be an objectToDelete() subroutine. In its clean-up handler, it would check for object class, do any class specific checking, and then call the delete method on the object. This would leave the current {groups,users,storages}ToDelete method to check to see if they got a GUID, build the object, and then push it onto objectToDelete.
I have been so busy writing new code with tests, that I haven't had any time over the last few weeks to write tests for the existing code. While this doesn't increase the technical debt of WebGUI, it doesn't reduce it either.
To those of you who read this blog, and want to start testing, I highly recommend that you start with perldoc Test::Tutorial. Chapter 1 of the WebGUI Deveoper's Guide has lots of information about testing, and some WebGUI specific testing issues as well.

Copyright 2010 perlDreamer Consulting | All Rights Reserved | Site Map | Graphic Design by Plain Black