Unit testing is an important practice for developing a system. There's many things to it, and many reasons behind it, things I'll probably get into at a later time. One of the aspects about HOW tests are written is the structure of the tests.
Since unit testing was introduced, there has been many ways of specifying unit tests. The usefulness of mocking frameworks has been more and more acknowledged, but the structure of tests have often suffered under immature frameworks (and languages!).
The structure of unit tests matter because it makes it
- easier to understand the usage of the code under test
- easier to change
- easier to fix
- easier to write. You should be able to do it in the natural way you think about it.
The Arrange, Act, Assert unit testing structure pattern is an old way of solving this. The concept is utterly simple to understand:
First you arrange the state of the test. The you act by executing the code that is tested. At last you assert by checking that what you expect to happen actually has.
Note: Both Typemock and RhinoMocks support the AAA syntax. That means you don't need to/shouldn't use the record/replay mode anymore.
No comments:
Post a Comment