Comments on: How to unit-test code that interacts with a database http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Xaprb http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-35785 Xaprb Fri, 29 Mar 2013 01:47:37 +0000 http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-35785 Yes, with a few more years under my belt this blog post is pretty funny for me to read :-)

]]>
By: Jess http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-35668 Jess Thu, 28 Mar 2013 00:35:29 +0000 http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-35668 Not to beat a dead horse, but I did want to agree that:

- What this article describes is not unit testing
- The idea that “mocking is the devil” indicates a clear lack of understanding of dependencies and dependency injection
- There -is- value in integration testing, but you cannot use that as justification against proper unit testing

Hope this helps any up-and-coming TDD’ers out there.
-Jess

]]>
By: John Battista http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-18456 John Battista Wed, 30 Jun 2010 18:03:51 +0000 http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-18456 Very interesting read. I just felt the need to point out that mock objects are necessarily the level of evil you make them out to be, especially if you have physical inputs to your system.

The difficulty in causes real physical interactions / conditions to control the output of sensors that is used by other objects requires construction of further physical interaction equipment with sensors ect.

In cases like that trying to create the physical interactions instead of mocking up the data streams is equivalent to trying to mock out a database instead of using a real one. You create a massive work burden on yourself that cannot really be fulfilled and used to test a full range of conditions. With mocks in a physical interaction system you can send in the full range of possible data in a fraction of the time at a fraction of the cost.

Just like any other tool its not good or bad, but it needs to be applied properly!

]]>
By: Rick http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-17510 Rick Tue, 29 Dec 2009 00:23:40 +0000 http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-17510 Guys,
is there any tool to do unit test on MySQL?
Thx.

]]>
By: Frank http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-17475 Frank Wed, 23 Dec 2009 23:30:04 +0000 http://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/#comment-17475 One approach we have used successfully was to embed the mysql server into our C++ test executables. At least for the relatively small database that the project included this worked reasonably well.
No modifications to the database access layer were necessary and creating a blank database was just a matter of copying some small files into a temporary directory. You loose the ability to easily debug the content of the database, but with some dump-tools this was not a big problem.

]]>