Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit used for integration tests with a class library

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?

like image 794
cdub Avatar asked Dec 12 '12 01:12

cdub


People also ask

Can NUnit be used for integration testing?

As seen above it is extremely easy to get NUnit to provide a simple way to integration test C# repositories and SQL code.

What is NUnit used for?

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.

What type of testing tool is NUnit?

NUnit is a Unit Testing framework that supports all the . NET languages. It was initially ported from JUnit.

Is NUnit a library?

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.


1 Answers

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

like image 195
Pablo Romeo Avatar answered Oct 27 '22 00:10

Pablo Romeo