我正在使用Visual Studio Developer Console运行xunit测试 . 具体来说,我的命令是 vstest.console "path/to/test.build.appxrecipe" /TestAdapterPath:"path/to/bin/debug/with/xunit/files" /platform:x64

但是,当我想使用ApplicationData类时,测试失败 . 看例外:

错误消息:System.InvalidOperationException:进程没有包标识 . (来自HRESULT的异常:0x80073D54)堆栈跟踪:在Windows.Storage.ApplicationData.get_Current()

我've tried looking into changing the console'的环境但不能确定错误意味着什么 . 是否与 Package.appxmanifest 文件有关?如陈述here . 也许this也是相关的 .

另一个有趣的事情是,使用NuGet包 xunit.runner.visualstudio ,我的TestExplorer窗口显示了我的所有测试,但无法运行它们 . 它给出了错误

entrypoint \ mytestproject.exe中没有可用的测试 . 确保已注册测试发现者和执行者,并且平台和框架版本设置是适当的,然后重试 .

虽然我已经覆盖了可能存在平台或框架不匹配的每个地方 . 但是,从我的命令中删除 /platform:x64 会导致上述错误 - 进一步说明......

尝试加载格式不正确的程序 .

最后,我的测试项目直接编译成exe文件是否正常?我找不到任何.dll的test.cs文件 .


Windows 10

Visual Studio社区版本15.6.6

xunit . *版本2.3.1