【发布时间】:2013-08-28 17:12:47
【问题描述】:
我编写了一个使用data source 属性的单元测试。
到目前为止,我一直在使用 完整路径,但我想将其替换为 相对路径。
但是从 C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe 执行测试并使用我的单元测试作为 dll 。 我想要来自单元测试位置的相对路径。
使用Environment.CurrentDirectory之类的方法或道具抛出编译错误:
An attribute argument must be a constant expression, typeof expression
or array creation expression of an attribute parameter
我还发现了变量 |DataDirectory|但它并没有真正的路径。
例如:
my unit test location is
c:\theproject\source\test\unittest\MyUnitTest.dll
and my excel file location is
c:\theproject\source\test\helpfiles\MyExcelFile.xlsx
我该怎么办?
【问题讨论】:
标签: c# unit-testing