In this week, I have uncovered a couple of bugs of existing Melange modules with the help of related test cases and sent pathes to the list, which again proves the importance of testing. I have also resolved the error "raise self.__TranslateError(e.application_error, e.error_detail) UnknownQueueError" by adding the path of taskqueue yaml setting file to the instantiation arguments list (root_path) of taskqueue_stub.TaskQueueServiceStub. Besides, I was also looking for a good way to test the mailing and taskqueueing functions in order to test that the correct mail has been sent out and the correct task has been scheduled. During my search, I found
gaetestbed which is very simple but serves the purpose well. Although it is not hard to make an equivalent one myself, why not reinvent the wheel if you can make use of an existing one. Its licence is also very generous (GNU V2). So, I added it to Melange tests and also extended its MailTestCase and TaskQueueTestCase and then put them into tests.util module. For MailTestCase, I overrided its assertEmailSent method to add two functions
- It will print out all sent messages to facilitate debug in case of failure.
- It accepts an optional argument n which is used to assert exactly n messages satisfying the criteria are sent out.
Later, I plan to add the functions of checking the CC field, allowing to partly match the subject field or even supporting regular expression. For TaskQueueTestCase, I have not added any functions yet. I further used them in my mail and taskqueue related tests, and cleaned up some of my existing testing code and then commited and pushed them to
my online clone. In addition, I have also done some new tests on gsoc tasks and statistics etc. and managed to increase the testing coverage of Melange to 59% and the coverage of almost all modules except one (with 39%) over 40%. In fact, the coverage report of the html version which apparently uses a different algorithm from the console one shows the overal testing coverage is already over 70%.
In the next week (the last week of GSoC2010), I will clean up code and commit and push all uncommited testing code, increase the overall coverage printed in console to over 60%, and make the coverage of most modules over 50%. In addition, I will also move the the gaetestbed and pymox modules to buildout dependency and add the experience of how to do mail and taskqueue related tests with gaetestbed to the testing wiki page.
No comments:
Post a Comment