
Improving Unit Test Stability with Transaction Handling
Enhance your unit tests by integrating transaction handling for improved stability and reliability. Explore the journey from manual processes to automated deployment, and discover the importance of transaction handling in unit testing to maintain data integrity and prevent failures.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Adding transaction handling to Unit Tests The why, the how and the journey
1992 -2012 VisualWorks & GemStone Feature branches Deployment was mostly a manual process No unit tests
2012 -2019 Trunk based development 90 % Deployment automated 55000 methods 8000 unit tests
No transaction handling in unit tests
receivedMessages process processedMessages 0 10 receivedMessages process processedMessages 9 0 failedMessages 1
receivedMessages process processedMessages 2 7 failedMessages 1
bT 1 Koos Sannie Koos Sannie bNT Koos Sannie Piet Koos Sannie Piet Marie 2 cT Piet Piet cT Commit both Commit nested, Abort nested, Commit outer Koos Sannie Koos Sannie Koos Piet Piet Piet Abort nested Commit nested, Abort outer (unit tests)
beginTransaction Check transaction level abortTransaction Transaction level 2 Transaction level 1 beginNestedTransaction abortTransaction Check transaction level abortTransaction Transaction level 2 Transaction level 1 beginNestedTransaction
commitTransaction Check transaction level commitTransaction Transaction level 2 Transaction level 1 beginNestedTransaction inTransaction Check transaction level Transaction level 2 Transaction level 1
beginTransaction Check transaction level System abortTransaction beginTransactionExplicityCalled := true Transaction level 2 Transaction level 1 System beginNestedTransaction abortTransaction Check transaction level System abortTransaction beginTransactionExplicityCalled := false Transaction level 2 Transaction level 1 System beginNestedTransaction
commitTransaction Check transaction level Check beginTransactionExplicityCalled commitTransaction beginTransactionExplicityCalled := false Transaction level 2 Transaction level 1 beginNestedTransaction inTransaction Check transaction level Check beginTransactionExplicityCalled Transaction level 2 Transaction level 1
methodA methodB self methodB self commit self commit methodA methodB self methodB self commit
Using framework Override defaultTransactionMode Commit test setup (especially when in manual mode)
Limitations Canonical framework Can t use nested transactions in our production code