我管理了 VisualStudio 2015 C++ 程序的测试项目,
它工作正常,但我想在 Linux 环境中运行相同的测试用例,
对于普通的 c++ 程序我有 make 文件,我不知道如何在 Linux 中运行 visual studio 2015 托管的 c++ 测试项目, 这是我的示例程序..
sample.h
#ifndef GUARD_SAMPLE
#define GUARD_SAMPLE
void method1();
void method2();
void method3();
我的c++程序是sample.cpp
#include "sample.h"
void method1()
{
int a,b=20,c=30;
a=b+c;
cout<<"sum is"<<a;
}
void method2()
{
int a,b=20,c=30;
a=b-c;
cout<<"sub is"<<a;
}
void method3()
{
int a,b=20,c=30;
a=b*c;
cout<<"mul is"<<a;
}
我的测试程序是sample_Test.cpp
#include "sample.h"
namespace sample_MDM_Test
{
[TestClass]
public ref class sample_Testing
{
public:
[TestMethod]
void Test_method1()
{
::method1();
}
[TestMethod]
void Test_method2()
{
::method2();
}
[TestMethod]
void Test_method3()
{
::method3();
}
我可以使用 make file 运行 c++ 应用程序,但是如何在 Linux 环境中运行这些单元测试功能(对于 windows 环境很好)。
请帮帮我
最佳答案
由于 sample_Test.cpp 不是 c++ 而是 c++/cli,因此您不能在 linux 环境中本地运行它。看这里Does Mono .NET support and compile C++ / CLI?了解更多信息。
如果您只需要 native c++,请查看 gtest/gmock 作为测试框架。这将在 Windows 和 Linux 上运行,并且有一个集成到 VS2015 中的测试适配器。
关于c++ - 如何在 Linux 中运行 visual studio 2015 managed c++ 测试函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45117777/