OpenCV provides unit tests for its important functions. In order to do that, it provides a unit test framework, which is built on top of gtest. However, the documentation on this test framework is really limited as it is not supposed to be used outsider OpenCV. I tried to manage to use OpenCV test framework based on this question. However, I cannot make the test framework only run specific test functions I wrote due to lack of documentation. Any ideas?
I finally find the solution: use --gtest_filter= option from the command line of the test program. This comes from the fact that OpenCV unit test is an improved version of GTEST.
Related
In eclipse cdt when I use the new class wizard, it asks if I want to add a unit test file, but I am not sure how to use that file, it does not follow any unit test framework. Am I supposed to just use it to write a main and execute it, or should I just ignore it and use a framework?
If you are not sure and you want to write unit tests, better use a dedicated framework. Eg. CppUTest is great here - and integrates well with eclipse (scroll down to "Related projects").
If you need just some basic unit tests you may use the one from eclipse.
It seems like OpenCV has a test framework based on GTest. They use it for their own unit tests, but I can not find documentation, examples or tutorials on how to use it outside of OpenCV.
It would be a perfect fit for the tests I intend to implement on our OpenCV-based library, but I do not really know where to start, as I am not really an expert in CMake (which builds our library).
I would very much appreciate help on the setup of some kind of "Hello ts World", i.e. how to configure the main CMakeList.txt and the one in the test directory in order to run tests like the ones found in the modules's test subdirectoriess (e.g. core's test folder)
After some research and tests, I answered my own question in my blog :
Using OpenCV's test framework (with CMake)
Again, I'm no CMake expert, so comments are welcome!
We are planning to integrate our native c++ projects into a maven build process. Further we want to formulate unit tests that are run automatically using the standard maven syntax (as for java unit tests) also for the c++ projects. Is this possible with c++ unit testing frameworks and if yes, which framework integrates well with maven ?
I would suggest to take a deep look into the maven-nar-plugin in relationship with Boost library which should fit your needs.
I am trying to make a standard class library in vs11 with more available classes than a library with metro offers (for example System.Console) and I cannot figure out how to create unit tests for it. I have tried looking through Google an nothing works. I actually had to go into vs2010, create the project, add the tests, and reopen in vs11. Was this functionality removed (which I doubt. I know unit testing is available)?
I have seen the unit test library project type, but it does not seem to support this type of library. What are my options?
Not sure what exactly you asking but If I understood you correctly, you want to create a standard class library and a standard Unit test project for the class library? Did you check the project templates under "Test". In here you can create a Unit Test project for the class library. You do not have to go to VS2010 and create a Test project then open it in VS. Apologies if that's not what you asking for.
As Raj said, just create a standard class library, reference the test framework you want to write tests in and then add test code as per usual.
For MSTest you need to add a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework and for the others use NuGet.
I have a blog post showing how the new unit test explorer works that might be helpful
I have been looking for specific properties from a unit test framework in c++ but I have struggled find all of the following properties in a framework:
Creation of Stubs (only in c++test).
Has Code-Coverage tool (only in c++test).
VS integration (Common enough)
Fixtures (very common in most c++ frame works)
Integration with a continuous build system (unable to find it at all in any Framework)
Predicate support (Very rare, only able to find that boost has this)
Anyone know of any frameworks which have all these properties (or most of them)?
GoogleMock from Google or Isolator++ from Typemock. Isolator++ is a mocking framework which works with several UT frameworks.
You don't need that as part of a UT framework (you can instrument binaries and get coverage in VS).
Isolator++ has VS integration AFAIK.
Like you are saying this is very common, so it will be hard to not find it in mainstream frameworks.
The continuous build system should support your framework if you really want that (TeamCity supports a couple of them for example). Otherwise you can always wrap it with some scripts.
Not sure what you require here.
HTH.