NUnit用于与类库的集成测试。

时间:2021-07-24 15:12:43

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?

我对NUnit是新手,但是由于旧项目的时间限制,我正在进行一些快速集成测试。我已经创建了一个测试数据库来进行测试,但是我如何连接它呢?

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?

我的NUnit项目是一个类库,它不能有web。配置或app.config以从其中提取连接字符串。我是将它更改为web项目还是应用程序项目(现在它只是一个类库),还是有什么原因要在NUnit代码中连接到数据库?

1 个解决方案

#1


5  

In fact your test project CAN have an app.config file. NUnit will load it correctly.

实际上,您的测试项目可以有一个app.config文件。NUnit将正确加载它。

http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/

http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/

This might also be useful: https://*.com/a/5821939/1373170

这也可能有用:https://*.com/a/5821939/1373170

#1


5  

In fact your test project CAN have an app.config file. NUnit will load it correctly.

实际上,您的测试项目可以有一个app.config文件。NUnit将正确加载它。

http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/

http://blog.coryfoy.com/2005/08/nunit-app-config-files-its-all-about-the-nunit-file/

This might also be useful: https://*.com/a/5821939/1373170

这也可能有用:https://*.com/a/5821939/1373170