集成测试 C++托管代码中来自 NUnit 的代码
我有一个用 C++ 编写的库,我想通过互操作从 C# 进行端到端测试。基本上这个库接受一些参数并在另一端吐出一个文件。我想将请求传递给 com 互操作,然后断言所有数据都已正确写入文件。
可以这样做吗?有更简单的方法吗?用pinvoke什么的?
谢谢
I have a library written in c++ that I want to end-to-end test from C# via interop. Basically this library takes in some parameters and spits out a file at the other end. I want to pass requests to a com interop and then assert that all the data was written correctly to the file.
Is it possible to do this? Is there an easier way? Using pinvoke or something?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会使用 C++/CLI 将 .net 测试和本机 C++ 代码粘合在一起。
它在实践中运行得很好:几个月前我遇到了类似的问题——想要验证我编写的 C++ 协议库是否可以与现有的 Java 实现进行互操作。为此,我对 C++ 代码使用了一个精简的 C++/CLI 填充程序,将 Java 构建为 J#,并用 C# 编写了测试。
I'd use C++/CLI for gluing together .net tests and native C++ code.
It works well enough in practise : I had a similar issue some months ago -- wanting to verify that a C++ protocol library I'd written would be interoperable with an existing Java implementation. For that I used a thin C++/CLI shim to the C++ code, built the Java as J#, and wrote tests in C#.