TestTransaction should implement Transaction instead of TransactionBase #1124
Labels
good first issue
Well written issue that is very specific and easy to do, intended for first time contributors.
Currently,
TestTransaction
implements TransactionBase, but still has acommit()
andclose()
method with the same signature as theTransaction
interface, which itself extendsAutoCloseable
. It should implementTransaction
instead.TestTransaction
also has adone()
method that does:Once
TestTransaction
isAutoCloseable
, inheriting that fromTransaction
, the calls todone()
can, and should, be converted to calls tocommit()
at the end of a try-with-resources block, and thedone()
method should be removed. This will make the lifecycle management of test transactions in the test code more clear, rather than relying on the impliedclose()
method inside thedone()
. It will also make the order ofcommit()
calls more clear when writing/maintaining test code. Withcommit()
hidden inside thedone()
method, it's not immediately obvious when they are called.This proposal would cause code written like:
to be written more explicitly as:
This example doesn't look that much better, but it's a big improvement when there are multiple transactions being created, committed, and closed in a test.
The text was updated successfully, but these errors were encountered: