diff --git a/Core/Code/Common/mitkTestingMacros.h b/Core/Code/Common/mitkTestingMacros.h index 66a34aabae..da2ae0420e 100644 --- a/Core/Code/Common/mitkTestingMacros.h +++ b/Core/Code/Common/mitkTestingMacros.h @@ -1,157 +1,187 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include namespace mitk { /** \brief Indicate a failed test. */ class TestFailedException : public std::exception { public: TestFailedException() {} }; } /** * * \brief Output some text without generating a terminating newline. Include * + * @ingroup MITKTestingAPI + * * */ #define MITK_TEST_OUTPUT_NO_ENDL(x) \ std::cout x ; -/** \brief Output some text. */ +/** \brief Output some text. + + @ingroup MITKTestingAPI +*/ #define MITK_TEST_OUTPUT(x) \ MITK_TEST_OUTPUT_NO_ENDL(x << "\n") /** \brief Do some general test preparations. Must be called first in the - main test function. */ + main test function. + + @ingroup MITKTestingAPI +*/ #define MITK_TEST_BEGIN(testName) \ std::string mitkTestName(#testName); \ mitk::TestManager::GetInstance()->Initialize(); \ try { -/** \brief Fail and finish test with message MSG */ +/** \brief Fail and finish test with message MSG + @ingroup MITKTestingAPI +*/ #define MITK_TEST_FAILED_MSG(MSG) \ MITK_TEST_OUTPUT(MSG) \ throw mitk::TestFailedException(); -/** \brief Must be called last in the main test function. */ +/** \brief Must be called last in the main test function. + * @ingroup MITKTestingAPI +*/ #define MITK_TEST_END() \ } catch (mitk::TestFailedException ex) { \ MITK_TEST_OUTPUT(<< "Further test execution skipped.") \ mitk::TestManager::GetInstance()->TestFailed(); \ } catch (std::exception ex) { \ MITK_TEST_OUTPUT(<< "std::exception occured " << ex.what()) \ mitk::TestManager::GetInstance()->TestFailed(); \ } \ if (mitk::TestManager::GetInstance()->NumberOfFailedTests() > 0) { \ MITK_TEST_OUTPUT(<< mitkTestName << ": [DONE FAILED] , subtests passed: " << \ mitk::TestManager::GetInstance()->NumberOfPassedTests() << " failed: " << \ mitk::TestManager::GetInstance()->NumberOfFailedTests() ) \ return EXIT_FAILURE; \ } else { \ MITK_TEST_OUTPUT(<< mitkTestName << ": " \ << mitk::TestManager::GetInstance()->NumberOfPassedTests() \ << " tests [DONE PASSED]") \ return EXIT_SUCCESS; \ } \ #define MITK_TEST_CONDITION(COND,MSG) \ MITK_TEST_OUTPUT_NO_ENDL(<< MSG) \ if ( ! (COND) ) { \ mitk::TestManager::GetInstance()->TestFailed(); \ MITK_TEST_OUTPUT(<< " [FAILED]\n" << "In " << __FILE__ \ << ", line " << __LINE__ \ << ": " #COND " : [FAILED]") \ } else { \ MITK_TEST_OUTPUT(<< " [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } #define MITK_TEST_CONDITION_REQUIRED(COND,MSG) \ MITK_TEST_OUTPUT_NO_ENDL(<< MSG) \ if ( ! (COND) ) { \ MITK_TEST_FAILED_MSG(<< " [FAILED]\n" << " +--> in " << __FILE__ \ << ", line " << __LINE__ \ << ", expression is false: \"" #COND "\"") \ } else { \ MITK_TEST_OUTPUT(<< " [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } /** * \brief Begin block which should be checked for exceptions * + * @ingroup MITKTestingAPI + * * This macro, together with MITK_TEST_FOR_EXCEPTION_END, can be used * to test whether a code block throws an expected exception. The test FAILS if the * exception is NOT thrown. A simple example: * MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ImageFileReaderException) typedef itk::ImageFileReader< itk::Image > ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName("/tmp/not-existing"); reader->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ImageFileReaderException) * */ #define MITK_TEST_FOR_EXCEPTION_BEGIN(EXCEPTIONCLASS) \ try { #define MITK_TEST_FOR_EXCEPTION_END(EXCEPTIONCLASS) \ mitk::TestManager::GetInstance()->TestFailed(); \ MITK_TEST_OUTPUT( << "Expected an '" << #EXCEPTIONCLASS << "' exception. [FAILED]") \ } \ catch (EXCEPTIONCLASS) { \ MITK_TEST_OUTPUT( << "Caught an expected '" << #EXCEPTIONCLASS \ << "' exception. [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } /** * \brief Simplified version of MITK_TEST_FOR_EXCEPTION_BEGIN / END for * a single statement + * + * @ingroup MITKTestingAPI */ #define MITK_TEST_FOR_EXCEPTION(EXCEPTIONCLASS, STATEMENT) \ MITK_TEST_FOR_EXCEPTION_BEGIN(EXCEPTIONCLASS) \ STATEMENT ; \ MITK_TEST_FOR_EXCEPTION_END(EXCEPTIONCLASS) -/** \brief Testing macro to test if two objects are (not) equal. +/** \brief Testing macro to test if two objects are equal. * * @ingroup MITKTestingAPI * * This macro uses mitk::eps and the corresponding mitk::Equal methods for all * comparisons and will give verbose output on the dashboard/console. * Feel free to implement mitk::Equal for your own datatype or purpose. * * @param OBJ1 First object. * @param OBJ2 Second object. * @param MSG Message to appear with the test. */ #define MITK_TEST_EQUAL(OBJ1,OBJ2,MSG) \ MITK_TEST_CONDITION_REQUIRED( mitk::Equal(OBJ1, OBJ2, mitk::eps, true)==true, MSG) + +/** \brief Testing macro to test if two objects are not equal. + * + * @ingroup MITKTestingAPI + * + * This macro uses mitk::eps and the corresponding mitk::Equal methods for all + * comparisons and will give verbose output on the dashboard/console. + * + * @param OBJ1 First object. + * @param OBJ2 Second object. + * @param MSG Message to appear with the test. + * + * \sa MITK_TEST_EQUAL + */ #define MITK_TEST_NOT_EQUAL(OBJ1,OBJ2,MSG) \ MITK_TEST_CONDITION_REQUIRED( mitk::Equal(OBJ1, OBJ2, mitk::eps, true)==false, MSG) diff --git a/Documentation/Doxygen/API/Groups/Modules.dox b/Documentation/Doxygen/API/Groups/Modules.dox index c07e0c1590..1d38cb322c 100644 --- a/Documentation/Doxygen/API/Groups/Modules.dox +++ b/Documentation/Doxygen/API/Groups/Modules.dox @@ -1,32 +1,30 @@ /** \defgroup ToolManagerEtAl Classes related to the Segmentation plugin \brief A couple of classes related to the Segmentation plugin. See also \ref QmitkSegmentationTechnicalPage */ /** \defgroup MITKModules MITK Modules \brief This group includes all MITK Modules. */ /** \defgroup MITKPlugins MITK Plugins \brief This group includes all MITK Plugins. */ /** \defgroup MITKExamplePlugins MITK Example Plugins \brief This group includes all MITK example plugins demonstrating specific framework features. */ /** \defgroup MITKTestingAPI MITK Testing - \brief This group includes all useful methods for testing. - - In this group, the API documentation of the methods for testing. The more general concepts of Testing in MITK are described on the \ref GeneralTests page. + \brief In this group, the API documentation of methods useful for testing is collected. The more general concepts of testing in MITK are described on the \ref GeneralTests page. */