简体   繁体   English

DeploymentItemAttribute不起作用(正确)

[英]DeploymentItemAttribute doesn't work (correct)

I have a Unit-TestClass. 我有一个单元测试类。 To test some functions for who i need database-access, i define the DeploymentItemAttribute at the head of the class directly after the TestClassAttribute. 为了测试需要我访问数据库的人员的某些功能,我在TestClassAttribute之后的类开头定义了DeploymentItemAttribute。

For some reasons, running the Testclass shows very different beheaivor depending on if i run all the test of my TestProject or Testing only this units by pressing STRG+R, T. 由于某些原因,运行Testclass会表现出截然不同的行为,具体取决于我是运行TestProject的所有测试还是通过按STRG + R,T仅测试此单元。

By using CTRL+R, T, all tests of the class will succeed. 通过使用CTRL + R,T,该类的所有测试将成功。 By running all the tests of the testproject, they will fail because they can't find the file. 通过运行测试项目的所有测试,它们将失败,因为它们找不到文件。 By right-clicking on the Testclass in the solution-explorer and click "Run Unit-Tests", they will also fail. 通过在解决方案资源管理器中右键单击Testclass并单击“运行单元测试”,它们也将失败。

I configured the file correctly. 我正确配置了文件。 It will "always copy". 它将“总是复制”。 More strangely, switching the deployment-flag in the testconfigurations will also invert the results. 更奇怪的是,在测试配置中切换部署标志也会反转结果。

Relying on my memory I can tell that by using CTRL+R, T you invoke default Microsoft's test runner, which deals with DeploymentItemAttribute as one would expect. 依靠我的记忆,我可以说,通过使用CTRL+R, T您可以调用默认的Microsoft测试运行程序,它可以像预期的那样处理DeploymentItemAttribute
But when you say: 但是当你说:

By running all the tests of the testproject, they will fail because they can't find the file. 通过运行测试项目的所有测试,它们将失败,因为它们找不到文件。 By right-clicking on the Testclass in the solution-explorer and click "Run Unit-Tests", they will also fail. 通过在解决方案资源管理器中右键单击Testclass并单击“运行单元测试”,它们也将失败。

I'm more then sure that these commands are provided by ReSharper , hence tests are run using ReSharper's test runner, which in the past had issues with this attribute . 然后,我更加确定这些命令是由ReSharper提供的,因此测试是使用ReSharper的测试运行程序运行的,该测试运行程序过去曾对此属性存在问题

As for the solutions to this problem there are some mentioned here and here , but they might depend on the version of ReSharper so you might want to google it up for your specific version. 至于解决此问题的方法, 这里这里都提到一些,但是它们可能取决于ReSharper的版本,因此您可能希望将其搜索为特定的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM