Opened 4 years ago

Closed 4 years ago

#23081 closed Bug (duplicate)

Documentation on testing should mention lack of integrity-related tests in TestCase

Reported by: jernej@… Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: mmitar@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using TestCase instead of TransactionTestCase, the documentation mentions that commit and rollback functionality cannot be tested. But as a consequence, since integrity constraints are deferred until a transaction is committed, also integrity errors are not tested when a transaction is simply rolled back after the test. This should probably be explicitly mentioned in the documentation.

Change History (6)

comment:1 Changed 4 years ago by Simon Charette

Triage Stage: UnreviewedAccepted

We should definitely mention it.

I wonder if it would be possible to SET CONSTRAINTS ALL IMMEDIATE on supported backends.

comment:2 Changed 4 years ago by Mitar

Cc: mmitar@… added

comment:3 Changed 4 years ago by Carl Meyer

I don't think setting constraints to immediate is a good plan; that would just be going from one "differs from production" scenario (constraints not enforced) to another (constraints enforced immediately, thus breaking any code that requires deferred constraints, such as circular FK references). It's not obvious that that's an improvement, therefore IMO we should stick with the simpler behavior (the current behavior).

comment:4 in reply to:  3 Changed 4 years ago by Simon Charette

Replying to carljm:

I don't think setting constraints to immediate is a good plan; that would just be going from one "differs from production" scenario (constraints not enforced) to another (constraints enforced immediately, thus breaking any code that requires deferred constraints, such as circular FK references). It's not obvious that that's an improvement, therefore IMO we should stick with the simpler behavior (the current behavior).

I agree that enforcing constraints on test setup might not a better a option but what about checking them on test tear down just before rolling back the transaction?

comment:5 Changed 4 years ago by Tim Graham

Duplicate of #22431

comment:6 Changed 4 years ago by Tim Graham

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top