获取TeamCity的阅读我N​​Unit测试配置文件

获取TeamCity的阅读我N​​Unit测试配置文件

本文介绍了获取TeamCity的阅读我N​​Unit测试配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NUnit和C#来测试我的应用程序在VS 2010中的一个项目。我的项目被称为MyProjectTests并按照NUnit的,我有,有一个连接字符串中有一个MyProjectTests.config文件,我的测试数据库中,像这样:

I have a project in VS 2010 using NUnit and C# to test my application. My project is called MyProjectTests and as per NUnit, I have a MyProjectTests.config file that has a connection string in it to my test database, like so:

<?xml version="1.0"?>
<configuration>
<appSettings>

    <add key="defaultConnection" value="MyConnection"/>
</appSettings>
<connectionStrings>
    <add name="MyConnection" connectionString="My_Connection_String_Details" providerName="System.Data.SqlClient"/>
</connectionStrings>

但是,当我跑我的TeamCity的NUnit的测试中,在连接字符串为空。如何使TeamCiry阅读我的连接文件?别的东西了?

But when I run my TeamCity NUnit tests, the connection string is Null. How do I make TeamCiry read my connection file? Is something else wrong?

推荐答案

您应该为您的设置文件的App.config,摆在测试项目的根目录下,并将其纳入。 NUnit的和TeamCity的选手既​​将使用该App.config中设置。

You should name your settings file as App.config, put in the root of test project and include it. NUnit and TeamCity runners both will use settings from that app.config.

这篇关于获取TeamCity的阅读我N​​Unit测试配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 09:41