[UWP] [C ++]使用C ++单元测试框架测试UWP App [英] [UWP][C++]Using C++ Unit Testing Framework to test UWP App

查看:89
本文介绍了[UWP] [C ++]使用C ++单元测试框架测试UWP App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我有一个C ++类,其中包含C ++ UWP App MyApp :: MyMath中的方法。
  2. 我创建了一个C ++单元测试项目来测试UWP应用程序。
  3. 我在单元测试应用程序中添加了对UWP应用程序的引用。
  4. 代码编译正常。
  5. 当我运行测试时,我收到错误

在0x7455DAD8(KernelBase.dll)中抛出异常UnitTests.exe:0x40080201:WinRT发起错误(参数:0x80040154,0x00000016,0x0ED5E798)。
$
UnitTests.exe中0x7455DAD8抛出异常:Microsoft C ++异常:Platform :: ClassNotRegisteredException ^在内存位置0x0ED5EC38。 HRESULT:0x80040154未注册的课程

Exception thrown at 0x7455DAD8 (KernelBase.dll) in UnitTests.exe: 0x40080201: WinRT originate error (parameters: 0x80040154, 0x00000016, 0x0ED5E798).
Exception thrown at 0x7455DAD8 in UnitTests.exe: Microsoft C++ exception: Platform::ClassNotRegisteredException ^ at memory location 0x0ED5EC38. HRESULT:0x80040154 Class not registered

我错过了哪一步?

谢谢,

Michael

#include "pch.h"
#include <CppUnitTest.h>


using namespace Microsoft::VisualStudio::CppUnitTestFramework;


namespace UnitTests
{
    TEST_CLASS(UnitTest1)
    {
    public:
        TEST_METHOD(TestMethod1)
        {
			auto test = ref new MyApp::MyMath; // class not registered error here

			test->Add(1, 2);
        }
    };
}

Michael S. Scherotter Media体验福音传教士微软公司http://blogs.msdn.com/synergist

Michael S. Scherotter Media Experience Evangelist Microsoft Corporation http://blogs.msdn.com/synergist

推荐答案

Hi Synergist,

Hi Synergist,

我能够在我身边重现这个问题。我创建了一个c ++ UWP应用程序并添加了一个mymath类,当我尝试在UnitTest中使用它时,我能够重现该问题。 

I was able to reproduce the issue on my side. I created a c++ UWP app and added a mymath class when i tried to use it in the UnitTest i was able to reproduce the issue. 

>> ; 在UnitTests.exe中的0x7455DAD8处抛出异常:Microsoft C ++
异常:Platform :: ClassNotRegisteredException ^在内存位置0x0ED5EC38。 HRESULT:0x80040154未注册的课程

查看我发现的例外情况  这个类似的线程。您可以查看
,看看是否存在类似问题。 请参阅@Alan Yao的回复,这可能有所帮助。 

Looking at the exeception i found this similar thread. Could you look at it and see that if that is similar issue. See @Alan Yao's Reply that might help. 

有问候,

Krunal Parekh 

Krunal Parekh 


这篇关于[UWP] [C ++]使用C ++单元测试框架测试UWP App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆