Automated testing avoid "weird" test script



What is "strange," the test script it? Is this script running in many cases, the test results are not always consistent, for example, run 10 times, 9 times is through, there is a failure 1, thenWhat this test be adopted, or is it failure? The answer is: It depends.

In some cases, that a failure, the program does catch a BUG.May be due to:

● program error after running for some time

● procedures to be wrong, but the error is not always happen

● In some special input into the error exposed under

However, in some cases, that the test failed 1 test is just to tell people, you write a "strange" the test script, achieving a strange test (Flakey Test).Unfortunately, the behavior of automated test results in a strange reason it becomes too much.Here are some common:

● competitive conditions

● inappropriate choice of test data

● pre-test conditions are not controlled

When they find a strange automated test scripts, must be determined to get rid of it:

● Use some common design patterns and effective use cases, such as "preparation, implementation, assertions (Arrange, Act, Assert)"

● Use MOCK Technology

In short, when there is a strange test (Flakey Test) was always very depressed, but in order not to face the future more depressed, and we have to get rid of those weird early detection test.