Weblog entry #48 for Steve

Site testing breakthrough...
Posted by Steve on Mon 28 Nov 2005 at 13:49
Tags: ,

The code which runs this site has a series of test cases which are regularly executed to make sure I've not broken anything.

Over the past few days I've achieved a milestone - we now have over 500 working test cases.

Some tests are not executed all the time; for example there is a test that ensures the menubar/login box is valid HTML. This test only runs if the perl HTML::Lint module is installed.

I'm pretty pleased with the way the testing is going, and it has definitely identified some bugs with the codebase. There is nothing quite so satisfying as adding new code and then testing that you've not broken anything by running all the tests!

Of course it is difficult to get started, and sometimes hard to think of what to actually test - something that I ignored when I wrote the simple perl testing introduction article...

For your amusement here is a complete test run:

skx@lappy:~/debian-administration$ make test
tests/add-no-follow............ok                                            
tests/breakup-text.............ok                                            
tests/modifier.................ok                                            
tests/modules..................ok                                            
tests/security-feed............ok                                            
tests/singletons...............ok                                            
tests/site-setup...............ok                                            
tests/templates................ok                                            
tests/test-admin...............ok                                            
tests/yawns-about..............ok                                            
tests/yawns-article-comment....ok                                            
tests/yawns-article............ok                                            
tests/yawns-comment-count......ok                                            
tests/yawns-items..............ok                                            
tests/yawns-poll-comment.......ok                                            
tests/yawns-poll...............ok                                            
tests/yawns-rss................ok                                            
tests/yawns-scratchpad.........ok                                            
tests/yawns-sidebar............ok                                            
tests/yawns-stats..............ok                                            
tests/yawns-users..............ok                                            
tests/yawns-user...............ok                                            
tests/yawns-weblog-comment.....ok                                            
tests/yawns-weblog.............ok                                            
All tests successful.
Files=24, Tests=512, 20 wallclock secs ( 9.54 cusr +  0.62 csys = 10.16 CPU)

Initially I wasn't testing the creation of new polls, weblogs, or articles. However I realised this could be done even on the live site with the following observations:

  • Article 0 doesn't exist.
  • Poll 0 doesn't exist.

So I now any test cases that need to deal with polls/articles can simply create a new article/poll with the id '0' - and not have to worry about upsetting the front page.

If you get fast and lucky you can see the temporary testing articles after they have been created, but before the test(s) execute and the result is removed. So far I've only managed it a few times - consider it a challenge ;)

In a similar vain the user tests each generate a random 8 character long username. This username is then tested to make sure it is not in use, created, tested, and deleted. This allows me to work upon a user without worrying that the name is already in use, and post comments & etc..

 

Comments on this Entry

Posted by uroboros (217.11.xx.xx) on Mon 28 Nov 2005 at 14:12
[ Send Message | View Weblogs ]
Thank you for your good work!

--
If you're smart enough to ask this question, you're smart enough to RTFM and find out yourself.

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Mon 28 Nov 2005 at 14:35
[ Send Message | View Steve's Scratchpad | View Weblogs ]

Cheers.

Sometimes I get apathetic and don't do much for a few days, but mostly its kinda fun to run a largish site and get the feeling I'm doing something useful.

Steve

[ Parent | Reply to this comment ]

Posted by uroboros (217.11.xx.xx) on Mon 28 Nov 2005 at 16:22
[ Send Message | View Weblogs ]
Yes, you are true, it is useful! :)

--
If you're smart enough to ask this question, you're smart enough to RTFM and find out yourself.

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search