view · edit · sidebar · attach · print · history

unser construction

Important

  1. Unit Test is a qualification of a system, but also it becomes an alternative of design document and usage document of the system
  2. So, the Unit Test must be updated with the corresponding source code
    • Otherwise, the unit test-cases will become useless

Basic Concept

  1. An Unit Test should be corresponding to one method, a test method name should be test_[method name] or test_[method name]__case123 if needed
  2. Integration Test or System Test should be designed separately from the Unit Test
    • If they are mixed in one test-case file, for example, it will be tough to maintain the test-cases
  3. We should consider Blackbox Test first, which means that we should check method interface (arguments and return values), do not care about the internal process and local (private) values
    • But if we use flexmock it means the test-case will also check implicitly the internal processes and values of method like 'Whitebox Test'
    • Although 'Whitebox Test' is sometimes useful to check the method process precisely, it will take much longer time to develop test-cases
  4. A Unit Test should be independent from the other libraries and modules by using flexmock
    • otherwise, one part updating may influence on many related test-cases
    • The relation or dependency among libraries should be tested by Integration Test or System Test
  5. Sometimes there should be several test-cases made for one method because of several processes in the method
    • If you have to prepare many test-cases for one method to make the coverage 100%, it may indicate the method is too complicated or too big.
    • You should consider if the method can be divided into several sub small methods, or if it is possible to use polymorphism instead of 'if' bifurcation
    • Basically, many 'if' conditions should NOT be implemented in one method in Object Oriented Probgramming
  6. You should NOT define the tested class again in the test-case file
    • It may influence on the other test-cases when you execute the test-case with suite.rb

References

view · edit · sidebar · attach · print · history
Page last modified on March 09, 2011, at 09:06 AM