问题描述
关于C ++单元测试框架的问题表明,之前没有发生过:使用C ++ / CLI和NUnit为本地C ++代码创建单元测试。
This answer to a question about C++ unit test frameworks suggests a possibility that had not occurred to me before: using C++/CLI and NUnit to create unit tests for native C++ code.
我们使用NUnit进行C#测试,使用它为C ++似乎很诱人。
We use NUnit for our C# tests, so the possibility of using it for C++ as well seems enticing.
我从来没有使用托管C ++,所以我的关注是这个方法有任何实际的限制吗?你们中有很多人在做这件事吗?如果是这样,你的经验是什么样的?
I've never used managed C++, so my concern is are there any practical limitations to this approach? Are many of you doing this? If so, what was your experience like?
推荐答案
我们有许多用C ++ / CLI编写的程序集,并使用C#和NUnit来测试它们。实际上,由于我们的目标是提供与C#很好地工作的程序集,这样做确保我们已经完成了。
We do this all of the time. We have many assemblies written with C++/CLI and use C# and NUnit to test them. Actually, since our goal is to provide assemblies that work well with C#, doing this makes sure that we have accomplished that.
你也可以在C ++ / CLI并调用非托管C ++。可能最好的方法是保持你的纯非管理C ++在一个lib,然后使用NUnit和链接到lib的测试程序集。
You can also write NUnit tests in C++/CLI and call unmanaged C++. Probably the best way is the keep your pure unmanaged C++ in a lib, and then make a test assembly that uses NUnit and links to the lib.
这篇关于使用CNU / CLI与NUnit的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!