简体   繁体   中英

Using xUnit test with UWP app on VS2015

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.

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:

Error Payload contains two or more files with the same destination path 'Assets\\SplashScreen.scale-200.png'. Source files: ...\\Projects\\Sample\\SampleUnitTest\\Assets\\SplashScreen.scale-200.png ...\\Projects\\Sample\\Sample\\Assets\\SplashScreen.scale-200.png SampleUnitTest

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

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.

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

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 ).

  • 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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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