-
Notifications
You must be signed in to change notification settings - Fork 25
Introduce test(no_rows) hint #2130
Description
Currently /*+test */ creates a snapshot for the results returned by the table the hint is annotating. This works great for tests where users want to assert a certain result set.
However, we are increasingly seeing users writing tests to assert that certain invariants are true and the way those are written is that they return empty tables if they are green (i.e. no records violate the invariant/condition) or the violating records if there are test failures.
That works great for testing conditions on lots of test data, but its a bit awkward with the current snapshot testing because it creates empty snapshots for all these tests and those need to be checked into the repository.
It would be cleaner to add a /*+test(no_rows) */ hint which extends the current hint with a parameter: no_rows. When that is set, the assertion is that the table returns no records. Hence, we don't need to create a snapshot: the test runner validates that the result set is empty and if it is not, it prints out all records as test failures.