MS测试:正在执行测试位置? [英] MS Test: Getting executing testlocation?

查看:64
本文介绍了MS测试:正在执行测试位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2010中的MS Test下运行测试时,如何找到执行程序集的等效路径?我需要知道测试从何处运行,以便可以为测试所需的数据文件设置相对路径.

How do I find the equivalent of a path to the executing assembly when running tests under MS Test in VS 2010? I need to know where the test is running from, so that I can set a relative path to a data file that it needs.

我正在尝试寻找与执行测试相同的路径,如果我在执行程序集上使用System.Reflection.Assembly.GetEntryAssembly().Location会得到该路径.感谢您的帮助.

I am trying to find the same sort of path to an executing test that I would get if I used System.Reflection.Assembly.GetEntryAssembly().Location on an executing assembly. Thanks for your help.

推荐答案

您可以使用自动部署文件进行测试.

You can use TestContext.DeploymentDirectory to get the test deployment directory. The test configuration allows you to automatically deploy files for tests.

这篇关于MS测试:正在执行测试位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆