sheredom / utest.h

🧪 single header unit testing framework for C and C++
The Unlicense
834 stars 57 forks source link

Randomize tests order #90

Closed emoon closed 2 years ago

emoon commented 2 years ago

Something that would be useful is to have tests running in a (optional) non-deterministic order. This allows catch a bunch of bugs such as:

  1. Tests by accident depend on data that has been generated by a previous test.
  2. Tests that runs after some tests happens depends on other tests data
sheredom commented 2 years ago

Good idea - you don't happen to know how best to do this? I could seed rand() or maybe a wang hash, but I'm not sure how best to guarantee that each test case will be visited?

emoon commented 2 years ago

Yeah, so there is thing thing https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle I have never implemented it myself, but it should (tm) be pretty straightforward.