Friday, November 12, 2010

Automated Testing VS. Unit Testing

I often hear the terms Automated Testing and Unit Testing used in a context that implies that they are one in the same. Lumping these buzz words is misleading and can scare people away from implementing simple automated testing techniques.

Let me describe the two terms with out all the mumbo jumbo and TDD propaganda...

Unit Testing: Testing each part of your code at a granular level.

Automated Testing: Testing by using an automated process that can report success or failure.

Don't assume that to implement automated testing you need to start writing unit tests against all of your code. This is daunting and involves effort, planning, and a shift in paradigm. This is why most development teams shy away from automated tasting. In reality, there are much lower hanging fruit in the automated testing world than unit testing....



Suppose your application is supposed to output 10 folders into C:/web/, each with an html, javascript, and css file within them. So whenever you change your source code, you verify that everything still outputs. So your manually testing your code via something like this:
  1. Delete C:/web/
  2. Run your app with correct params
  3. Open C:/web/
  4. Verify folders and files exist
  5. Verify that there is data in the files
This is a fairly tedious test that could easily be automated. JUnit would be a great tool for this (Junit has an unfortunate name because it implies it is only for unit testing.) You could easily create a JUnit test that would do each step for you, and then display green for success or red for failure.

If your not yet doing automated testing, try to think of tasks that you do during development and testing that could be automated, forget about unit testing for now. Check out this article to learn how to create automated tests using JUnit. Like most it focuses on unit testing, but don't get hung up on that.