Thursday, December 19, 2013

Parametrized JUnit tests with JUnitParams

Parameterized unit tests are used to to test the same code under different conditions. Thanks to parameterized unit tests we can set up a test method that retrieves data from some data source. This data source can be a collection of test data objects, external file or maybe even a database. The general idea is to make it easy to test different conditions with the same unit test method, which will limit the source code we need to write and makes the test code more robust. We can call these tests data-driven unit tests.

The best way to achieve data-driven unit tests in JUnit is to use a JUnit's custom runner - Parameterized or JUnitParams' JUnitParamsRunner. Using JUnit's approach may work in many cases, but the latter seems to be more easy to use and more powerfull.

Tuesday, December 17, 2013

Fixing someone else's code

Collective code ownership is very important part of any successful Agile project where everyone in the team shares responsibility for the quality of code. Any developer can change the code, fix the bug he notices and refactor as the code belongs to the team.

Wednesday, December 4, 2013