Friday, September 23, 2005

About Unit Tests

Recently I have written many tests to make sure the functionalities I have implemented were running okay. I wanted to test small parts of my code if they are doing what they were supposed to do: these tests are called by most of us unit tests. When you test a stand-alone component from the outside, meaning you don't explicitly use knowledge of the internal structure, you are using the "black-box" design technique. In this case you may call your tests component tests.

Michael Feathers wrote an article about unit testing rules and has tried to pull a line between the real unit tests and the tests that are not unit tests. In my opinion, unit tests should avoid talking to a database, communicating across network, etc. However, when you write tests that do this, so the unit-test-concept should not be violated, you may name your tests with the purpose of their creation: component tests, integration tests, performance tests, etc.

Unit tests should always run fast whenever we re-test our code - in this point I totally agree with Michael Feathers .

Technorati tags: Eclipse, Unit-test.