c# - 使用 NUnit 进行单元测试时获得所需/正确的装配路径

标签 c# unit-testing nunit .net-4.5 shadow-copy

我刚刚开始试验最小起订量以对我的模块进行单元测试。

实际上,我必须为其编写单元测试的类使用

Assembly.GetExecutingAssembly().Location 在内部确定路径。

但是,这在编写单元测试时不起作用,因为执行程序集的路径不同(采用单元测试程序集的路径)

AppData\\Local\\Temp\\3ylnx32t.ukg\\TestApplication.Test\\assembly\\dl3\\aeb938e6\\f3664631_d982ce01

我试过了,禁用卷影复制。

AppDomainSetup appDomain= new AppDomainSetup{ShadowCopyFiles = "false",};
appDomain.ShadowCopyFiles=false.ToString();

还是不行!

如有任何建议,我们将不胜感激。提前致谢。

最佳答案

您可以使用TestContext.CurrentContext.TestDirectory as mentioned by Charlie Poole from NUnit here .

引用:https://stackoverflow.com/a/29057351/589574

关于c# - 使用 NUnit 进行单元测试时获得所需/正确的装配路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17698694/

相关文章:

c# - 如何使用 C# 从服务器获取打印机详细信息

python - 如何测试django中的编辑功能? (错误 django.db.utils.IntegrityError : NOT NULL constraint failed)

asp.net-mvc - 在 MVC 3 中模拟 session

f# - 如何将函数传递给NUnit Throws Constraint?

c# SqlBulkCopy - 热获取原始 sql 查询

c# - 如果我想实现这个线程概念,我应该如何使用 TPL?

javascript - 将 C# 数组传递给参数中的 Jquery 函数

ios - 使用 Jenkins 对 iOS 进行单元测试

c# - 如何在 NUnit 中编写需要括号的流畅约束

测试桌面应用程序