3 ms·
I'm a big believer in unit tests, but to be fair, this rule isnt quite accurate. Suppose I write a test as follows: Assert(rand() % 2 == 0); When the test get
by chacham15 8y ago
I'm a big believer in unit tests, but to be fair, this rule isnt quite accurate. Suppose I write a test as follows:
Assert(rand() % 2 == 0);
When the test gets run the first time, it can pass and the code can be admitted, but when the next person goes to add code, it can fail. At this point, you've broken your defining principle: that all the code in the test base is correct. The answer of what to do here isnt clear as its a tradeoff in time spent fixing the tests (or potentially the test framework) and developing features. If you have deadlines this becomes more tenuous. Then you figure out that the reason the test is flaky is because it isnt being run in a real environment...etc.
All I'm saying is that it isnt as simple as this "Rule" would like to have you believe.