Name: [002] Ian Ozsvald
Member: 104 months
Authored: 181 videos
Description: I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production company `ProCasts <http://procasts.co.uk>`_: .. image:: http://procasts.co.uk/media/procasts_sma ...

Robust and Reliable Web Sites with twill and nosetests [ID:209]

a series of video-tutorials by Ian Ozsvald

Learn how to use twill (a Python+shell web browser) and nosetests to unit-test your website as if you were using the website. With this technique you can reliably test your site whilst you develop.

This is also known as 'functional testing' and it is used within ShowMeDo to test our website before deployment, and used by many larger sites for robust testing.

Publishing schedule - 5 videos will be published by the first week of April.

Video Tutorials

1. 3 Minute Overview

We're going to use twill (installing twill) and nosetests (installing nosetests) to test the behaviour of ShowMeDo.com - you can use the same techniques to add reliable and repeatable tests to your own website. Repeatable tests help you to avoid errors during the development cycle which helps to reduce the amount of time that humans have to spend repetitively testing the same features in a websit [...]

2. Test a page exists - 200 OK

First we check that a page exists at the url we specify and that it generates a 200 OK - use this to confirm that your major pages are present. We use the twill API to 'go' and 'get_http_code'. I also discuss a development tip - use '1/0' to force an error condition when developing your tests, with liberal use of 'print' statements, so you can confirm that the test works as you desire.

3. Test for a 404 Not Found

Next we check that an incorrect URL generates a 404 Not Found error. Use this to confirm your error-handling as Not Found errors are very common on live websites.

4. Using Test Classes, Test Title and Link

For our third test we write a class-based test and look at the setUp and tearDown methods. During the test we confirm that our page's title looks right and that a link exists. We then follow the link and confirm that we end up on the correct page (in case the website was using a redirect - though our's isn't). I also show another way of running a unit test by using the format 'nosetests file.py: [...]

5. Test Logins using Form Manipulation

Finally we look at manipulating the form so that our session can login. We use this to both confirm that our login process works and to check that the logged-in user's page contains the html that we expect. We use the 'fv' command to fill in form values using a dummy ShowMeDo user account and then 'submit' to act as though we pressed the login button. You can extend this technique to use 'for [...]

Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Ian

Learning Paths

This series lies on the following learning-paths. Learning-paths are a new initiative at Showmedo, to start structuring our content better. You can find out more here.

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com