在测试中使用项目内容

发布于 2024-08-30 07:24:06 字数 296 浏览 4 评论 0原文

我正在使用 Visual Studio 2010 及其集成测试功能。
我的项目中有一个 XML 文件,该文件设置为复制到输出目录。当我编译和运行项目时,我可以很好地访问该文件。但是当我尝试在 TestMethod 中访问它时它不存在。

看起来测试是在工作目录设置为 TestResults 目录中创建的“Out”目录的情况下运行的。我可以在使用该文件之前设置断点。如果我随后将文件复制到此“Out”目录中并继续运行测试,它将正确访问该文件。但这并不是我真正希望自动化测试发挥作用的方式。

是否可以告诉 VS 将构建目录复制到此工作目录中?

I am working with Visual Studio 2010 and it's integrated testing functionality.
I have an XML file in my project which is set to copy to the output directory. I can access the file just fine when I compile and run the project. But it doesn't exist when I attempt to access it within a TestMethod.

It looks like the test is run with the working directory set to an "Out" directory created within the TestResults directory. I can set a breakpoint before I use the file. If I then copy the file into this "Out" directory and continue running the test it accesses the file properly. But that is not really how I want my automated tests to function.

Is it possible to tell VS to copy the build directory into this working directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心安伴我暖 2024-09-06 07:24:06

我找到了一些解决方案。虽然我对此不太满意。

测试->编辑测试设置下,我编辑当前设置。
部署选项卡下,选中启用部署复选框。在要部署的其他文件和目录中添加 bin\Debug 目录(看起来像 src\LocalModels.test\bin\Debug)

我想你可以添加你需要的每个文件,这会有点快点。这一切似乎有点可笑。

I found somewhat of a solution. Though I'm not too happy with it.

Under the Test->Edit Test Settings I edit the current settings.
Under the Deployment tab, check the Enable deployment checkbox. In the Additional files and directories to deploy add your bin\Debug directory (looks something like src\LocalModels.test\bin\Debug)

I suppose you could add each file you need and it would be a bit faster. It all seems a bit ridiculous.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文