开发者

VS2008 Unit Testing System.IO.FileNotFoundException on XML input file (with "Copy Always")

I added a HolidaysSchedule.xml file to my Unit Test, and set it's property "Copy to output directory" to "Copy Always".

This file contains the holidays of my client.

When I do a "Debug Tests in Current Context" on a specific test that I wrote to check to see if a date is a holiday, I get this error.

Test method FRB.EC.Utils.MiscUnitTests.ConsoleAdminXMLHoliday.Test_July4_2010 threw exception:  Syst开发者_StackOverflowem.IO.FileNotFoundException: Could not find file 'c:\Source\Dev\Utils\TestResults\myuser_mymachine 2010-07-07 14_25_25\Out\HolidaysSchedule.xml'..

How do I get the file to copy to the appropriate testing/runtime directories? I could use an absolute disk/path reference, but I was hoping to make it relative to the /bin directory.


Two problems:

1) I was lacking the "s" in HolidaysSchedule.xml filename. So of course, always check the exact spelling. But then had exact same issue.

2) Based on this page: http://msdn.microsoft.com/en-us/library/ms182475.aspx

I did the following: In VS2008, clikcked "Test" from menu bar, then "Edit Test Run Configurations", then "Local test run". Then I clicked "Deployment" on the left, then clicked the "Add File" button and added my HolidaysSchedule.xml file, then saved and rerun the test, which then worked fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜