
Several little tidbits:
The last tidbits are more than bullet points. One of the goals that I set for the WebGUI tests is that each test should clean up after itself, so that anything it adds, removes or changes does not affect other tests. In theory, this would also make it safe to run on a production site.
For the most part, the tests do a good job of cleaning up, but it's quite tedious to keep track of all the changes and to manually revert them in END blocks in EVERY test. So, with a lot of help from Haarg (aka Graham Knop), I've been adding code to WebGUI::Test to make this easier.
WebGUI Settings
At the beginning of each test, a snapshot of the entire set of WebGUI settings is taken, and then restored at the end of the test.
WebGUI Configuration
Currently, you can register configuration setting and have them automatically restored at the end of the test, using the originalConfig method:
WebGUI::Test->originalConfig($param);
That will find the current configuration setting, make a safe copy using Clone of it if it needs to, and then restores it at the end of the test. Haarg is looking at changes to Config::JSON and WebGUI::Config to make it easy to clone the entire config and restore it, just like the settings.
WebGUI::Storage locations
Similarly, you can register Storage locations to be cleaned up at the end of the test.
WebGUI::Test->storagesToDelete($storageObj);
This is particularly nice because in order to clean up storage locations in an end block, they have to be visible in scope to the top of the test script. In other words, using SKIP blocks to not run tests makes cleaning up storage locations hard. Now you can create the storage location whereever, and WebGUI::Test will track it and clean it up for you.
WebGUI::Groups
WebGUI::Test->groupsToDelete($group)
will do the same for groups. Just be sure not to register any default groups...
What's next?
Well, it would be nice to handle users, and version tags as well. It would be good to have checks so that default users and groups are not deleted by accident. It would be nice if each method would take either an object, or a GUID for recreating the object.
Finally, there may be some good in convenience methods for creating users, groups and storage locations that automatically register themselves to be deleted.
Remember, writing tests helps keep WebGUI stable and bug free, and is a great way to learn how to use the WebGUI API.
People in every country receive the home loans from different banks, just because that's simple.

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