This post is part of the Setting up a full stack for web testing series.

The initial setup of the testing framework is very crucial. You need to make it as easy and fast as possible for all developers to run the tests. You also need to make sure those tests are executed automatically even when developers become too lazy. That second part I’ll cover in the continuous integration post at a later stage.

In my opinion, setting up a good framework is the most important work you do when it comes to testing. Any work you do here will be multiplied later when you and your team spend less time on writing the tests.

I recommend you start by just adding a tests folder to your project and include one empty feel-good test. See below for a Python example of such a test.

Most modern web frameworks already include a complete framework ready to run. Ruby on Rails started that trend and almost every modern MVC framework comes with a similar testing framework. So chances are that all the hard work has already been done for you. Refer to your framework’s documentation for details.

If you aren’t using a web framework, here are some pointers for getting started outside of that context:

For all of these tools I tried to find a tutorial that shows how to set up a full test, though they aren’t all very complete. If the tutorial doesn’t cover that part yet, spend some additional time to make the tests runnable on the command line with just one command. To achieve that, the Ruby example above uses Rake, nose is already a one-stop testing tool and Java developers commonly use Ant. In PHP projects I have used Rake as well, to run all the tests in a project easily.

If your work mainly in an IDE, you may want to get good integration to execute tests easily as well. I can’t give you good pointers for that, as the configuration is very different between IDEs. But you’ll easily find the required information with any search engine.

The tests I usually include to make sure the framework is up and running are these two:

def test_true():
    assert True

def test_false():
    assert False

This is Python code to be run with nose. But translating that to your framework won’t be a problem.

If you have good tutorials for other languages and frameworks, please leave them in the comments so I can include them in the article.