ibm-js / dapp

AMD-based Application Framework for building Web & Mobile applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dapp unit test: should not rely on execution order of test cases

edchat opened this issue · comments

Or if a test does have to rely on the execution order of the tests in the test suite there should be a warning in the test so that updates to the test do not break things by changing the order.

I apologize for dropping in, I was just Googling "Unit test execution order " as 'proof' for colleagues to point out unit tests should be independent and not rely (or be hampered by) on other tests, a.k.a. the order in which they're executed.

I am a firm believer that unit tests should be interdependent and be able to run in random order.
The downside is, you may need to perform per-test set-up and cleanups of testdata.
On the upside, you have higher certainty a failing test means the system being tested was changed and the assertions in that test itself are no longer correct.

At a previous employer, the unit test execution order was actually automatically hustled each time new tests were added or removed, enforcing this principle to a good degree.

Having a code base where the unit tests allow a higher degree of certainty regarding the correctness is rather comfortable when diagnosing and analyzing issues- it can save lots of time.