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
What Is Java Unit Testing? Java unit testing is the practice of applying the unit testing method to individual units of Java source code
A unit test generally only tests out one small piece of functionality, and you’ll usually write a bunch of unit tests to make sure your code handles a variety of conditions. By running unit tests on your code, you can be more confident that your change didn’t break anything. JUnit is a library that helps us write unit tests.
CppUnit. The premier unit testing framework for C++; you can also use it to test C code. It is stable, actively developed, and has a GUI interface. The primary reasons not to use CppUnit for C are first that it is quite big, and second you have to write your tests in C++, which means you need a C++ compiler.
Unit tests are small programs that you write to test out your “real” code. A unit test generally only tests out one small piece of functionality, and you’ll usually write a bunch of unit tests to make sure your code handles a variety of conditions. By running unit tests on your code, you can be more confident that your change didn’t break anything.
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++).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With