Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Line-of-Business (LOB) .NET Applications?

I was wondering if anyone here has experience in unit testing LOB applications (typically CRUD).

I have dabbled in the built-in unit testing tools in Visual Studio, but I have found it difficult to run tests that hit a database. Since the data changes, and combined with the fact that I have little idea what I'm doing, it seems very difficult to produce expected results and assert against them. Also I've even heard that you shouldn't run unit tests against databases... but how does everyone else out there perform unit tests on CRUD LOB software?

I hear so much about TDD and continuous integration with testing, but it seems like if i can't even create unit tests to begin with, I can't really use those methodologies. It makes since that a product like Notepad would be an easy one to create unit tests for... you have a certain amount of features and those features should always produce the same result. But with LOB applications, you've got things like Sales Orders that could be created or deleted or modified in your testing environment.

Any insight would be appreciated!

like image 251
Paul Avatar asked Jan 04 '09 23:01

Paul


1 Answers

Typically with CRUD you are going to need to either Mock or use an IOC Container for your data access layer so you aren't always hitting the database and "changeable data".

With unit tests, you always expect the same values, so having it hooked up to a database is typically going to cause problems.

Check out RhinoMocks or Inversion Of Control Containers.

like image 137
Tom Anderson Avatar answered Sep 27 '22 18:09

Tom Anderson