在 VS2015 上使用带有 UWP 应用的 xUnit 测试 [英] Using xUnit test with UWP app on VS2015

查看:13
本文介绍了在 VS2015 上使用带有 UWP 应用的 xUnit 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是这个问题的后续.我按照此处所述的步骤操作,示例测试按预期工作.这是我第一次接触到这个工作示例,但请等待真正的工作设置,这正是我遇到问题的地方.

This is a follow-up to this question. I followed the steps as described here and the sample tests work as expected. This is the first time I got to this working sample, but wait for the real working setup which is where I am having trouble.

作为测试我的应用程序的下一步,我使用添加引用..."将我的 UWP 应用程序项目添加到 xUnit 测试项目.现在,在我引用我的项目后,当我运行测试(在测试资源管理器窗格 VS2015 中运行全部)时,我收到以下错误:

As a next step to testing my app, I added my UWP app project using "Add Reference..." to the xUnit Test project. Now, after I referencing my project, when I run the test (Run All in Test Explorer pane VS2015) I get the following error:

错误有效负载包含两个或多个具有相同目标路径AssetsSplashScreen.scale-200.png"的文件.源文件:...ProjectsSampleSampleUnitTestAssetsSplashScreen.scale-200.png...ProjectsSampleSampleAssetsSplashScreen.scale-200.png SampleUnitTest

还有两个错误,与上面完全一样,但参考了Square150x150Logo.scale-200.pngSquare44x44Logo.targetsize-24_altform-unplate.png 图像文件.

There are two more errors, exactly as above, but referring to Square150x150Logo.scale-200.png and Square44x44Logo.targetsize-24_altform-unplated.png image files.

我能理解这些错误的含义;被测试的应用程序和测试项目都生成用于相同输出的视觉资源(闪屏图像、徽标、任务栏图标等),但这些是注册应用程序和运行(在本地计算机上)所必需的我的情况).我从来没有遇到过两个项目输出相同视觉资源的有争议的问题,希望有人知道如何解决这个问题.如果我将项目更改为 Class 项目,则单元测试不起作用,因此这不是一个选项.

I can understand what these errors mean; the app being tested and the test project both generate visual resources (splash-screen image, logo, taskbar icon, etc.) destined for the same output but these are required to register the app(s) and run (on a local machine in my case). I've never come across such a contentious issue of two projects outputting the same visual resources and hopefully someone knows how to solve this. The unit test doesn't work if I change the project to Class project, so that is not an option.

您如何处理 xUnit 测试项目和正在测试的项目之间存在争议的情况(wrt 视觉资源)?

How do you deal with the contentious situation (wrt visual resources) between an xUnit test project and a project being tested?

推荐答案

好的,我想出了如何解决位于 Assets 文件夹中的视觉资源之间的冲突,但这导致 xUnit (这将是我的后续问题).

Okay, I figured out how to resolve the conflict between the visual resources residing in the Assets folder, but this leads to a new kind of issue for the xUnit (which will be my follow-up question).

  • 对于 xUnit 项目,将 Assets 文件夹重命名为 Images(或任何您认为更好的替代名称).
  • 指向 xUnit 项目下的 Package.appxmanifest 文件并将其作为代码文件打开.为此,请选择 Package.appxmanifest 文件并按 F7,或右键单击该文件并选择查看代码上下文菜单命令.
  • 在代码文件中,将文件夹名称 Assets 替换为 Images 或您选择用来重命名 Assets 文件夹的任何名称.保存它.
  • For the xUnit project, rename the Assets folder to, say, Images (or whatever you think is a better alternative name).
  • Point to the Package.appxmanifest file under xUnit project and open it as a code file. To do this, select the Package.appxmanifest file and press F7, or right-click the file and select the View Code context menu command.
  • In the code file, replace the folder name Assets with Images or whatever you chose to rename the Assets folder with. Save it.

现在测试项目将在没有视觉资源输出冲突的情况下编译和运行.然而,关于 xUnit,我们将遇到另一个问题,如我的下一个问题.

Now the test project will compile and run with no visual resources output conflicts. With regard to xUnit however, we'll hit another problem as described in my next question.

这篇关于在 VS2015 上使用带有 UWP 应用的 xUnit 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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