About Unit Testing

About Unit Testing

Unit testing provides a structured and automated way of testing individual components of a system. As a methodology, unit testing has many advantages over manual, ad-hoc testing and debugging. Benefits which are easy to understand lists below,

  • Because each unit test focuses specifically on an individual method, you can more easily determine the source of a failure for a failing unit test.
  • Such a collection of tests is very useful for regression testing. As you implement new features, you can rerun existing tests to ensure that existing functionality has not been broken.
  • Unit tests also serve as documentation for users of the methods under test. Developers can quickly review unit tests to determine exactly how particular components should be consumed.
Unit testing is a popular concept in application development. And in community, there are many unit testing tools for application developers, such as jUnit, NUnit, CppUnit etc. They all are the instances of the xUnit architecture for unit testing frameworks. With help of unit testing tool, Test Driven Development (TDD) is more popular in these days.

One typical development flow segment of TDD is,

During this flow, practitioners also refer to the green state when all tests are passing and red state when some tests are failing. The little picture below depicts this little state machine.

DB unit testing just is reflecting of unit testing in database field. It has the same benefits as application unit testing.

Standard test case often is made of 4 sub-processes, including execute setup, run test, verify test result, execute teardown.

posted @ 2011-04-07 21:01 harrychinese 阅读(...) 评论(...)  编辑 收藏