2 Nov 00:25
Run SQLObject with a mock database connection?
Matthew Wilson <matt <at> tplus1.com>
2008-11-01 23:25:07 GMT
2008-11-01 23:25:07 GMT
I've got a lot of complex logic in some of my SQLObject methods, and I'd like to verify that they work in unit tests, and I don't want to have any kind of database connection, not even a SQLite in-memory database. For example, I've got a parent-child relationship inside of one table, where rows have an optional "parent row" field. I want to set the status on the parent row based on the status of all the different children. For example: When all the children have a status AAA, I'll set the parent status to AAA. When all the children have a status BBB, I'll set the parent status to BBB. When the children have different status, I'll set the parent status to 'Mixed'. Of course, this is a simplification of something much uglier. I want to make sure I execute the correct logic by feeding in lots of possible scenarios through my function. The test will run much faster if I can fake the connection to a database. Is this possible? Any advice on mocking or stubbing a database connection is welcome.(Continue reading)





RSS Feed