本机C ++单元测试的部署项目 [英] Deployment Item for Native C++ Unit Tests

查看:91
本文介绍了本机C ++单元测试的部署项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为Native C ++单元测试部署测试文件?我可以分发部署项目以供测试在.Net单元测试中使用: 

Is there a way to deploy test files for Native C++ unit tests?  I can distribute deployment items for the test to work with in .Net unit tests:  

如何:部署用于测试的文件

[TestClass]
class TestClass1
{
  [TestMethod]
  [DeploymentItem("source", "targetFolder")]
  public void Test1()
  {
    string testData = System.IO.File.ReadAllText(@"targetFolder\source");
    ...
} }

是否可以使用Native C ++单元测试来做同样的事情?  

Is there a way to do the same thing with Native C++ unit tests?  

单元测试本机代码...

#include "stdafx.h"
#include <CppUnitTest.h>
#include "..\MyProjectUnderTest\MyCodeUnderTest.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
TEST_CLASS(TestClassName)
{
public:
  TEST_METHOD(TestMethodName)
  {
    // Run a function under test here.
    Assert::AreEqual(expectedValue, actualValue, L"message", LINE_INFO());
  }
}

我有一个Native C ++库,需要使用部署项目(文本文件等)进行测试.当前,我正在手动"执行此操作, -我已编写代码以 TEST_CLASS_INITIALIZE 方法分发文件.

谢谢,

I have a Native C++ library that I need deployment items (text files etc.) to test with.  Currently I am doing this "by hand" - I have written code to distribute files in the TEST_CLASS_INITIALIZE method.

Thanks,

汤姆

推荐答案

汤姆,

之前我也对此问题进行过研究,没有官方文档向我们提供有关VC ++中部署属性的简单示例,我怀疑它对这种特定语言是否有限制.

I also did some research about this issue before, no official document shared us a simple sample about the deployment attribute in VC++, I doubt that it has a limitation for it for this specific language.

一种解决方法是,您可以添加一个新项目->测试设置",然后以这种方式添加部署项目:

One workaround is that you could add a new item ->Test Settings, and then add the deployment items like this way:

但是对于本文档这样的部署属性:

But for the deployment attribute like this document:

我怀疑它的局限性,如果可能的话,我们可以在此处提交反馈:

I doubt that it has a limitation for it, if possible, we could submit a feedback here:

http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx 也许 我们可以从产品团队成员那里直接获得解决方案.

http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx,maybe we could get the directly solution from the product team members.

此致

Jack


这篇关于本机C ++单元测试的部署项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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