New feelings of unit testing

xiaoxiao2021-03-06  36

1. Try to make the operation performed inside the test method can be captured outside.

2, try to use functions without the process.

3. For uncertain data, it is best to introduce the outside. For example, in the process, based on time generate document numerals, the time is preferably introduced outside, otherwise it will not be tested.

4. For a large number of tests that need to be covered, please do not use hard coding. Instead, read from the outside, as if Java has a set unit test, Jetif can read the 'sample data' and 'result data' from the metadata. Maybe Dunit is not, you can only write it yourself.

5, the unit test itself please do not 'Copy & Paste', otherwise you will be exhausted.

6, you need to write a lot of preparation data, but behavior is relatively simple, you can not use unit testing.

7. Try not to test the internal analog button on the unit. (This should be what other automated test tools).

8. If the code of the unit test is more than 5 times longer than your application's code, you have to optimize it.

转载请注明原文地址:https://www.9cbs.com/read-53391.html

New Post(0)