Unit tests are deterministic

Our unit test is deterministic. Non-deterministic unit tests are the nightmare of the developers. If you are in a group where some builds break on the CI server, and when a build breaks, your fellow developer says that you just have to try it again; no way! If a unit test runs, it should run all times. If it fails, it should fail no matter how many times you start it. A non-deterministic unit test, in our case, will be to render random numbers and have them sorted. We will end up with different arrays in each test run and, in case there is some bug in the code that manifests for some array, we will not be able to reproduce it. Not to mention that the assertion that the code was running fine is also difficult.

If we sorted a random array in a unit test (something we do not), we could, hypothetically, assert that the array is sorted, comparing the elements one after the other checking that they are in ascending order. It would also be a totally wrong practice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.182.66