DeploymentItem fails copying directories when there are multiple test projects per solution

一曲冷凌霜 提交于 2019-12-06 10:47:51
PlaceboZA

This question is quite old, but could still benefit others. Especially since I ended up here :)

It seems that DeploymentItemAttribute doesn't support using the same source path name in multiple test classes. Note: I said same path name, not physical folder (think different test projects with same folder name to deploy).

However the destination folder name can be different, with no ill effects.

My suggestion is:

  1. Create a fixture base class (if you prefer, in separate project)
  2. Add the attribute: [TestClass, DeploymentItem("LanguageData", "LanguageData")]
  3. Change your OcrTests and OcrBuilderTests classes to inherit the new class.
  4. Remember to remove the deploymentitem attributes for 'LanguageData' from OcrTests and OcrBuilderTests

I've tried this, with Great Success. In my case, I had a common test fixture project and multiple test projects, each using the base class.

Unfortunately the DeploymentItemAttribute is filled with Gotchas, see here for more.

Tried your approach but still it did not copy folder properly, so what i did instead copied files not directories(maybe this helps someone):

[TestClass]
[DeploymentItem("connectionStrings.config")]

// should be able to do this, but it does not work always, only sometimes
//[DeploymentItem("Configs", "Configs")]

// this instead should work always
[DeploymentItem("Configs\\file1.txt", "Configs")]
[DeploymentItem("Configs\\file2.txt", "Configs")]
[DeploymentItem("Configs\\file3.txt", "Configs")]
.....
[DeploymentItem("Configs\\filen.txt", "Configs")]
public class BaseTests
{
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!