diff --git a/cmake/OpenCVFindMatlab.cmake b/cmake/OpenCVFindMatlab.cmake
index a66c21e03..922d31372 100644
--- a/cmake/OpenCVFindMatlab.cmake
+++ b/cmake/OpenCVFindMatlab.cmake
@@ -7,6 +7,7 @@
 #   MATLAB_FOUND:       true/false
 #   MATLAB_ROOT_DIR:    Root of Matlab installation
 #   MATLAB_MEX_SCRIPT:  The mex script used to compile mex files
+#   MATLAB_BIN:         The actual Matlab executable
 #   MATLAB_INCLUDE_DIR: Path to "mex.h"
 #   MATLAB_LIBRARY_DIR: Path to mex and matrix libraries
 #   MATLAB_LIBS:        The Matlab libs, usually mx, mex, mat
@@ -119,8 +120,12 @@ function(locate_matlab_components MATLAB_ROOT_DIR)
   # get the mex shell script
   find_file(MATLAB_MEX_SCRIPT_ NAMES mex mex.bat PATHS ${MATLAB_ROOT_DIR}/bin NO_DEFAULT_PATH)
 
+  # get the Matlab executable
+  find_file(MATLAB_BIN_ NAMES matlab matlab.exe PATHS ${MATLAB_ROOT_DIR}/bin NO_DEFAULT_PATH)
+
   # export into parent scope
   if (MATLAB_MEX_SCRIPT_ AND MATLAB_LIBS_ AND MATLAB_INCLUDE_DIR_)
+    set(MATLAB_BIN         ${MATLAB_BIN_}         PARENT_SCOPE)
     set(MATLAB_MEX_SCRIPT  ${MATLAB_MEX_SCRIPT_}  PARENT_SCOPE)
     set(MATLAB_INCLUDE_DIR ${MATLAB_INCLUDE_DIR_} PARENT_SCOPE)
     set(MATLAB_LIBS        ${MATLAB_LIBS_}        PARENT_SCOPE)
@@ -151,7 +156,7 @@ if (NOT MATLAB_FOUND)
   endif()
   find_package_handle_standard_args(Matlab DEFAULT_MSG MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIR 
                                            MATLAB_ROOT_DIR MATLAB_LIBS   MATLAB_LIBRARY_DIR 
-                                           MATLAB_MEXEXT MATLAB_ARCH)
+                                           MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
 
   # if Matlab was not found, unset the local variables
   if (NOT MATLAB_FOUND)
diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt
index 6e3efe1e2..1bc12ff05 100644
--- a/modules/matlab/CMakeLists.txt
+++ b/modules/matlab/CMakeLists.txt
@@ -46,14 +46,16 @@ ocv_add_module(matlab   BINDINGS opencv_core opencv_imgproc
                                  opencv_highgui opencv_ml opencv_calib3d opencv_photo
                                  opencv_nonfree opencv_calib)
 
-set(HDR_PARSER_PATH ${OPENCV_MODULE_opencv_python_LOCATION}/src2)
-
-# get the include path of the Bridge
-prepend("-I" MEX_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
+if (BUILD_TESTS)
+    add_subdirectory(test)
+endif()
 
 # ----------------------------------------------------------------------------
 #  Configure time components
 # ----------------------------------------------------------------------------
+set(HDR_PARSER_PATH ${OPENCV_MODULE_opencv_python_LOCATION}/src2)
+prepend("-I" MEX_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 message("-- Trying to generate Matlab code")
 execute_process(
     COMMAND ${PYTHON_EXECUTABLE} 
@@ -124,3 +126,7 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
       DEPENDS opencv_matlab_sources
   )
 endforeach()
+
+# ----------------------------------------------------------------------------
+#  Install time components
+# ----------------------------------------------------------------------------
diff --git a/modules/matlab/test/CMakeLists.txt b/modules/matlab/test/CMakeLists.txt
index cfe3b328c..d9faf0f5b 100644
--- a/modules/matlab/test/CMakeLists.txt
+++ b/modules/matlab/test/CMakeLists.txt
@@ -1,8 +1,5 @@
-# glob the source files
-file(GLOB SOURCE_FILES *.cpp)
-
-# compile each source
-foreach(SOURCE_FILE_ ${SOURCE_FILES})
-  get_filename_component(SOURCE_FILE_NAME_ ${SOURCE_FILE_} NAME_WE)
-  add_custom_target(${SOURCE_FILE_NAME_} ALL ${MATLAB_MEX_SCRIPT} ${SOURCE_FILE_})
-endforeach()
+# run the matlab test suite
+add_test(opencv_matlab_test
+    COMMAND ${MATLAB_BIN} "-nodisplay" "-r" "testsuite.m"
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
diff --git a/modules/matlab/test/OpenCVTest.m b/modules/matlab/test/OpenCVTest.m
new file mode 100644
index 000000000..df97a6c5e
--- /dev/null
+++ b/modules/matlab/test/OpenCVTest.m
@@ -0,0 +1,17 @@
+% Matlab binding test cases
+% Uses Matlab's builtin testing framework
+classdef OpenCVTest < matlab.unittest.TestCase
+
+  methods(Test)
+    
+    % check if the autogenerated functions can be found
+    function randExists(testcase)
+      try
+        cv.rand();
+      catch
+        testcase.verifyFail();
+      end
+      testcase.verifyTrue(true);
+    end
+  end
+end
diff --git a/modules/matlab/test/cv_exception.cpp b/modules/matlab/test/cv_exception.cpp
new file mode 100644
index 000000000..3343f2cd3
--- /dev/null
+++ b/modules/matlab/test/cv_exception.cpp
@@ -0,0 +1,33 @@
+/*
+ * file:   exception.cpp
+ * author: Hilton Bristow
+ * date:   Wed, 19 Jun 2013 11:15:15
+ * 
+ * See LICENCE for full modification and redistribution details.
+ * Copyright 2013 The OpenCV Foundation
+ */
+#include <exception>
+#include <opencv2/core.hpp>
+#include "mex.h"
+
+/* 
+ * exception
+ * Gateway routine
+ *   nlhs - number of return arguments
+ *   plhs - pointers to return arguments
+ *   nrhs - number of input arguments
+ *   prhs - pointers to input arguments
+ */
+void mexFunction(int nlhs, mxArray* plhs[],
+                 int nrhs, const mxArray* prhs[]) {
+
+  // call the opencv function
+  // [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
+  try {
+    throw cv::exception;
+  } catch(cv::exception& e) {
+    mexErrMsgTxt(e.what());
+  } catch(...) {
+    mexErrMsgTxt("Incorrect exception caught!");
+  }
+}
diff --git a/modules/matlab/test/exception.cpp b/modules/matlab/test/exception.cpp
new file mode 100644
index 000000000..7362e698c
--- /dev/null
+++ b/modules/matlab/test/exception.cpp
@@ -0,0 +1,29 @@
+/*
+ * file:   exception.cpp
+ * author: Hilton Bristow
+ * date:   Wed, 19 Jun 2013 11:15:15
+ * 
+ * See LICENCE for full modification and redistribution details.
+ * Copyright 2013 The OpenCV Foundation
+ */
+#include "mex.h"
+
+/* 
+ * exception
+ * Gateway routine
+ *   nlhs - number of return arguments
+ *   plhs - pointers to return arguments
+ *   nrhs - number of input arguments
+ *   prhs - pointers to input arguments
+ */
+void mexFunction(int nlhs, mxArray* plhs[],
+                 int nrhs, const mxArray* prhs[]) {
+
+  // call the opencv function
+  // [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
+  try {
+    throw 1;
+  } catch(...) {
+    mexErrMsgTxt("Uncaught exception occurred!");
+  }
+}
diff --git a/modules/matlab/test/std_exception.cpp b/modules/matlab/test/std_exception.cpp
new file mode 100644
index 000000000..1da41e3ba
--- /dev/null
+++ b/modules/matlab/test/std_exception.cpp
@@ -0,0 +1,32 @@
+/*
+ * file:   exception.cpp
+ * author: Hilton Bristow
+ * date:   Wed, 19 Jun 2013 11:15:15
+ * 
+ * See LICENCE for full modification and redistribution details.
+ * Copyright 2013 The OpenCV Foundation
+ */
+#include <exception>
+#include "mex.h"
+
+/* 
+ * exception
+ * Gateway routine
+ *   nlhs - number of return arguments
+ *   plhs - pointers to return arguments
+ *   nrhs - number of input arguments
+ *   prhs - pointers to input arguments
+ */
+void mexFunction(int nlhs, mxArray* plhs[],
+                 int nrhs, const mxArray* prhs[]) {
+
+  // call the opencv function
+  // [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
+  try {
+    throw std::exception();
+  } catch(std::exception& e) {
+    mexErrMsgTxt(e.what());
+  } catch(...) {
+    mexErrMsgTxt("Incorrect exception caught!");
+  }
+}
diff --git a/modules/matlab/test/testsuite.m b/modules/matlab/test/testsuite.m
new file mode 100644
index 000000000..3fc274ef2
--- /dev/null
+++ b/modules/matlab/test/testsuite.m
@@ -0,0 +1,5 @@
+%setup the tests
+opencv_tests = OpenCVTest();
+
+%run the tests
+result = run(opencv_tests);