在 VS2015 上使用 xUnit 测试 UWP 应用程序
Testing UWP app with xUnit on VS2015
我已经成功地在 VS2015 上创建了一个 xUnit 项目来对 UWP 应用程序进行单元测试。这个问题的背景 为这个问题提供了一些背景信息。
我可以编译和运行测试,但是当我引用要测试的项目时,出现以下错误。
------ Run test started ------
Updating the layout...
Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete (1857ms). Full package name: "8f4533e5-fec8-415b-94ab-6bce6b37374f_1.0.0.0_x86__5gyrq6psz227t"
A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
========== Run test finished: 0 run (0:00:04.3378913) ==========
我知道引用的项目(将进行单元测试)导致 a user callback threw an exception
,但我看不到调试此错误的明显方法。执行模式看起来不像是可以用断点检查的普通调试。
有人知道如何深入研究并找出导致 a user callback threw an exception
错误的原因吗?要测试的应用项目没有错误,运行本身没问题。
好的,做了一些研究 self-learning 现在我可以回答我自己的问题了。
最重要的事实:
You cannot unit test a UWP project, only a class library (at this time).
以上是 Jerry Nixon 的 quote(见链接页面末尾)。所以,这说明了一切,但不知道这个重要事实无疑会让你像我一样陷入困境。
上面的意思是,如果你还没有这样做,你需要将你的应用程序项目拆分为 UI 部分(视图和其他 UI 相关部分),以及休息到 non-UI 库项目(包括模型、数据访问方法等); non-UI 图书馆项目成为 unit-tested 的候选。幸运的是,使用我的应用程序很容易实现这一点,现在我可以通过引用测试项目中的 class 库部分来对我的应用程序最关键的部分进行单元测试。对以后也有启发。
因此,上述错误是由于引用了一个 UI 目前无法测试的负载 UWP 项目。
我已经成功地在 VS2015 上创建了一个 xUnit 项目来对 UWP 应用程序进行单元测试。这个问题的背景
我可以编译和运行测试,但是当我引用要测试的项目时,出现以下错误。
------ Run test started ------
Updating the layout...
Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete (1857ms). Full package name: "8f4533e5-fec8-415b-94ab-6bce6b37374f_1.0.0.0_x86__5gyrq6psz227t"
A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
========== Run test finished: 0 run (0:00:04.3378913) ==========
我知道引用的项目(将进行单元测试)导致 a user callback threw an exception
,但我看不到调试此错误的明显方法。执行模式看起来不像是可以用断点检查的普通调试。
有人知道如何深入研究并找出导致 a user callback threw an exception
错误的原因吗?要测试的应用项目没有错误,运行本身没问题。
好的,做了一些研究 self-learning 现在我可以回答我自己的问题了。
最重要的事实:
You cannot unit test a UWP project, only a class library (at this time).
以上是 Jerry Nixon 的 quote(见链接页面末尾)。所以,这说明了一切,但不知道这个重要事实无疑会让你像我一样陷入困境。
上面的意思是,如果你还没有这样做,你需要将你的应用程序项目拆分为 UI 部分(视图和其他 UI 相关部分),以及休息到 non-UI 库项目(包括模型、数据访问方法等); non-UI 图书馆项目成为 unit-tested 的候选。幸运的是,使用我的应用程序很容易实现这一点,现在我可以通过引用测试项目中的 class 库部分来对我的应用程序最关键的部分进行单元测试。对以后也有启发。
因此,上述错误是由于引用了一个 UI 目前无法测试的负载 UWP 项目。