Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is what I found but I'm not sure if this is the right way or not. The make process actually prints out the jar name of the junit tests for OpenCV java wrappers (opencv-test.jar). Here is how to run it.

  1. Install JRE for your platform. I have Mac so further examples will work for unix and the likes. MS Win I guess works in the similar fashion, just need to use proper path syntax.
  2. Navigate to /opencv/build folder and run the following command:

    java -cp ./modules/java/pure_test/.build/lib/junit-4.11.jar:./modules/java/pure_test/.build/build/jar/opencv-test.jar:./bin/opencv-310.jar -Djava.library.path="./lib" junit.textui.TestRunner org.opencv.test.opencv-package-name.test-class-name

opencv-package-name stands for the name of the corresponding opencv module, for example calib3d, core, features2d, highgui, imgproc, objdetect, photo, utils, video etc.

test-class-name can be any class from that package, which inherits from OpenCVTestCase. For example:

java -cp ./modules/java/pure_test/.build/lib/junit-4.11.jar:./modules/java/pure_test/.build/build/jar/opencv-test.jar:./bin/opencv-310.jar -Djava.library.path="./lib" junit.textui.TestRunner org.opencv.test.utils.ConvertersTest

will produce the following output:

.........................................

Time: 0.295

OK (41 tests)

Here is what I found but I'm not sure if this is the right way or not. The make process actually prints out the jar name of the junit tests for OpenCV java wrappers (opencv-test.jar). Here is how to run it.

  1. Install JRE for your platform. I have Mac so further examples will work for unix and the likes. MS Win I guess works in the similar fashion, just need to use proper path syntax.
  2. Navigate to /opencv/build folder and run the following command:

    java -cp ./modules/java/pure_test/.build/lib/junit-4.11.jar:./modules/java/pure_test/.build/build/jar/opencv-test.jar:./bin/opencv-310.jar -Djava.library.path="./lib" junit.textui.TestRunner org.opencv.test.opencv-package-name.test-class-name

opencv-package-name stands for the name of the corresponding opencv module, for example calib3d, core, features2d, highgui, imgproc, objdetect, photo, utils, video etc.

test-class-name can be any class from that package, which inherits from OpenCVTestCase. For example:

java -cp ./modules/java/pure_test/.build/lib/junit-4.11.jar:./modules/java/pure_test/.build/build/jar/opencv-test.jar:./bin/opencv-310.jar -Djava.library.path="./lib" junit.textui.TestRunner org.opencv.test.utils.ConvertersTest

will produce the following output:

.........................................

Time: 0.295

OK (41 tests)

UPDATE: as expected things are much more simple than we think of them initially )) OpenCV good team did great job already - all tests including java tests can be run from the build directory by this command:

python ../modules/ts/misc/run.py

more information is here. The only confusing part of documentation - seems like this command actually runs all tests so it can be used not only for performance control.