Testing UWP app with xUnit on VS2015

与世无争的帅哥 提交于 2019-12-05 18:33:01

Okay, did some researching and self-learning and now I can answer my own question.

The most important fact:

You cannot unit test a UWP project, only a class library (at this time).

The above is a quote from Jerry Nixon (see toward the end of linked page). So, that says it all, but not knowing this important fact will no doubt set you on a wild goose chase as it did to me.

What the above means is that, if you haven't done already, you need to split your app project into the UI part (View and other UI related parts), and the rest into non-UI library project (comprising models, data access methods, etc.); the non-UI library project being the candidate to be unit-tested. Fortunately, it was easy to accomplish this with my app and now I can unit test the most crucial parts of my app by referencing the class library part in the test project. Is was also instructive for the future.

The above error is therefore due to referencing a UI laden UWP project which cannot be tested at this time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!