WinUI Desktop Unit Tests
文章介绍如何将Project Union的打包项目(wapproj)和目标项目(csproj)整合成一个项目。使用的是下面的预览特性:
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
但是却发现REGDB_E_CLASSNOTREG,无法进行下去。评论区有人有同样的经历。不过至少展示了一个方向,未来这两个项目会合一。
其他参考:
- Automated Unit Testing: MSTest vs XUnit vs NUnit
- Getting Started with xUnit.net Universal Windows Apps (UWP) with Visual Studio Test Explorer
- NET Core 2: Why xUnit and not NUnit or MSTest
- Running Universal Windows unit tests from the command line
- Question: How to write UI tests in WinUI 3 Desktop #3282
- WinUI3 + MSTest #708
Walkthrough: Create and run unit tests for UWP apps
通过VS工程模板Unit Test App (Universal Windows)
来创建一个测试项目。如果要让TestExplorer出来应有的TestMethod1,得执行Run all才行。
Ditch that Packaging Project with the Windows App SDK (Windows UI)
这篇文章介绍使用Single-project MSIX Packaging Tools来把打包工程和目标工程合二为一。
需要添加,launchSettings.json,内容如下:
{
"profiles": {
"NoPackagingProjectRequired": {
"commandName": "AppContainer"
}
}
}
注意,上述文件要放在Properties目录下,且要将NoPackagingProjectRequired替换成具体的程序名。
需要在项目文件中添加:
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<WindowsPackageType>MSIX</WindowsPackageType>
需要把非打包项目在Configuration Manager里面勾选Deploy。
针对C++项目
vcxproj不需要launchSettings.json,在添加
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<WindowsPackageType>MSIX</WindowsPackageType>
的同时,需要吧<AppxPackage>false</AppxPackage>
改为true。
然后需要在Debug > Xxx Debug Properties中Configuration Properties的Debugging中的Debugger to Launch改成Local Machine。
WinAppDriver相关状态
- Unable to run WinAppDriver with https://github.com/microsoft/WinUI-3-Demos #1261
- https://github.com/Microsoft/Microsoft.Windows.Apps.Test
其他
- Windows 11 and the Windows App SDK
- Getting TAEF unittests to work with a C++/WinRT XAML Islands application
- TAEF Overview
- Test Authoring and Execution Framework (TAEF)
- WinUI-3-Demos
(本篇完)