单元测试 C++使用Java代码
我继承了一个巨大的 C++ 代码库和一些集成测试。这是一个向许多下游系统提供数据的关键系统。由于测试非常不可靠,我们的团队无法自信地推动更改。
我们想在系统中引入一些测试,但大多数开发人员都有Java背景。我们有什么选择?
1) 学习 C++
2) 使用 JNI :不确定这有多容易
I have inherited a huge c++ codebase with some integration tests. This is a critical system which feeds data to a lot of downstream systems. As the tests are very unreliable our team is not able to push changes confidently.
We want to introduce some tests in the system but most of the developers have Java background. What options do we have ?
1) Learn C++
2) Use JNI : Not sure how easy that is
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 JNI 又增加了一层复杂性,但您仍然将学习 C++ - 如果您不想使用 C++,我不会推荐它。
根据 C++ 系统的功能,您可以选择不同的测试策略。根据我的经验,我有一个负责数据处理的系统,所有数据都是通过网络发送的。在这种情况下,测试是在 python 中完成的:
我的情况很幸运,因为通信是通过网络连接完成的(我们实际上可以使用无论我们想要什么语言)。
如果除了 C++ 之外你不能使用其他任何东西,我认为你必须使用 C++(而不是 Java + JNI + C++)。
Using JNI adds another layer of complexity and still you will learn C++ - I wouldn't recommend it if you don't want to use C++.
Depending on what the C++ system does you can choose different testing strategies. In my experience I had a system which was responsible for data processing and all the data was sent via network. In this case the tests were done in python:
My case was a lucky one since the communication was done via a network connection (we could literally use whatever language we wanted).
If you cannot use anything else but C++ I think you will have to do it in C++ (and not Java + JNI + C++).
我建议您尝试 JNA 它不需要您编写 C 或 C++ 代码。它比 JNI 慢,但对于测试来说这不太重要。
I would suggest you try JNA which doesn't require you to write C or C++ code. Its slower than JNI, but for tests that is unlikely to matter.