I am new to NUnit, but for time constraints on an old project, I am doing some quick integration tests. I have created a test database to test against, but how do I connect to it?
My NUnit project is a class library, and that can't have a web.config or app.config to pull the connection string from. Do I change it to a web project or some application project (it's just a class library now) or is there some why to connect to the database in the NUnit code?
As seen above it is extremely easy to get NUnit to provide a simple way to integration test C# repositories and SQL code.
NUnit provides a console runner (nunit3-console.exe), which is used for batch execution of tests. The console runner works through the NUnit Test Engine, which provides it with the ability to load, explore and execute tests.
NUnit is a Unit Testing framework that supports all the . NET languages. It was initially ported from JUnit.
A unit is the smallest testable part of any software. NUnit is a unit-testing library for all . NET languages. It was inspired by Java's JUnit.
In fact your test project CAN have an app.config file. NUnit will load it correctly.
http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/
This might also be useful: https://stackoverflow.com/a/5821939/1373170
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With