I am writing unit tests on queries where the results must be returned in a specific sorted order. We are using the Java H2 in memory database.
I want to make sure that the "order by" statements are being executed correctly. I'm not trying test H2, I accept it's correct, I'm trying to test that I have issued correct the SQL statement to return the correctly sorted results.
I'm thinking something like a way to tell H2 to randomise the results each time before sorting or perhaps some kind of SQL insertion that inserts rows in a random order to the tables each time. Hopefully this tests the ordering is correct. I know it's no guarantee because the database determines it's own internal order but thought I'd throw it in as an idea I was thinking about.