简体   繁体   English

如何为C ++和C#创建一个测试项目

[英]How do I make a single test project for C++ and C#

I'm kind a newbie in .net stuff, however I'm developing a same project in two languages, C++ and C#; 我是.net方面的新手,但是我正在用两种语言C ++和C#开发同一个项目。 nothing too complicated, just a couple of classes in each project that basically do the same. 没有什么太复杂的,每个项目中只有几个类基本上可以做到相同。

Now, I need to make a single test project for both sets of code, so my question is how can I make a project, most likely a console project, in which I can include the c# classes along with the c++ classes. 现在,我需要为这两组代码创建一个测试项目,所以我的问题是如何创建一个项目(最有可能是控制台项目),在其中可以将c#类和c ++类一起包含在内。

When I run the console project I want to be able to do something like: 当我运行控制台项目时,我希望能够执行以下操作:

  • C# /s {methodname} | C#/ s {方法名} | /i {parameter} / i {参数}
  • C++ /s {methodname} | C ++ / s {方法名} | /i {parameter} / i {参数}

I hope you can understand what I mean. 我希望你能理解我的意思。

As long as the C++ is fully managed, you can call it from another .NET assembly written in any language. 只要对C ++进行了完全管理,您就可以从以任何语言编写的另一个.NET程序集中调用它。

For testing however, I would recommend going with a test framework like NUnit or MbUnit instead of writing your own in a console application. 但是,对于测试,我建议使用NUnitMbUnit之类的测试框架,而不是在控制台应用程序中编写自己的测试框架。 They will provide you with a much more robust testing environment. 他们将为您提供更强大的测试环境。

由于它是.NET,难道不能只添加引用和using语句,然后使用“ / cpp”或“ / csharp”选项吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM