1
你好 我有一個UnitTest項目,我添加了多個App.config文件(從不復制到輸出目錄)。我已經爲我需要的不同配置創建了runtestconfig文件。TestRunConfig不復制App.config文件
<DeploymentItem filename="Config01\App.config" />
我每次運行使用MSTest的
mstest.exe /runconfig:Config01.testrunconfig /testcontainer:MyTests.dll
或使用VS2008主動配置的項目,我的測試失敗。 在解決方案輸出目錄中,App.config文件永遠不會被複制。
這是一個測試前:
[TestMethod]
public void TestAge()
{
string value = ConfigurationManager.AppSettings["age"];
Assert.AreEqual(value, "21");
}
,這是錯誤:Assert.AreEqual failed. Expected:<(null)>. Actual:<21>.
我在做什麼錯?