Difference between revisions of "Unit Testing"

From PCGen Wiki
Jump to: navigation, search
(New page: ==Introduction== Testing is the most important thing a code monkey ever does. You should always write a [http://www.junit.org/ JUnit] test for each new bit of code (or fix) that you devel...)
 
(No difference)

Latest revision as of 03:38, 3 August 2008

Introduction

Testing is the most important thing a code monkey ever does. You should always write a JUnit test for each new bit of code (or fix) that you develop. PCGen has a very large and complex code base, and your small change can easily break something unforseen down the line, running the test suite reduces this risk heavily.

Here is how to test the Unit Tests you have written:

  1. Test: ant clean test
  2. Lather, rinse, repeat.

If all goes well, you will see the success.notice target echo output in ant. If things go wrong, the failure.notice target echoes output instead: investigate the output to see what failed.

Alternatively, you can do the same with maven and produce a site report on unit tests: maven site

The advantages is a nicely linked report with red/green markers and test metrics. The disadvantage is that it takes considerably longer as maven generates many reports, not just the one for unit tests.

Any questions, comments etc are welcome!