Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitk::TestFixture Class Reference

Test fixture for parameterized tests. More...

#include <mitkTestFixture.h>

Inherits TestFixture.

Inherited by mitkAnisotropicIterativeClosestPointRegistrationTestSuite, mitkAnnotationTestSuite, mitkArbitraryTimeGeometryTestSuite, mitkArrayTypeConversionTestSuite, mitkBandpassFilterTestSuite, mitkBaseDataTestSuite, mitkBaseGeometryTestSuite, mitkBeamformingFilterTestSuite, mitkCastToFloatImageFilterTestSuite, mitkCESTDICOMReaderServiceTestSuite, mitkChartExampleTestSuite, mitkClassificationTestSuite, mitkColorBarAnnotationTestSuite, mitkColorSequenceRainbowTestSuite, mitkCompositePixelValueToStringTestSuite, mitkCovarianceMatrixCalculatorTestSuite, mitkCropImageFilterTestSuite, mitkCropTimestepsImageFilterTestSuite, mitkCustomTagParserTestSuite, mitkDICOMDCMTKTagScannerTestSuite, mitkDICOMPropertyTestSuite, mitkDICOMTagPathTestSuite, mitkDispatcherTestSuite, mitkEqualTestSuite, mitkExampleDataStructureReaderWriterTestSuite, mitkExampleDataStructureTestSuite, mitkExceptionTestSuite, mitkFloatToStringTestSuite, mitkGenericIDRelationRuleTestSuite, mitkGeometry3DEqualTestSuite, mitkGeometryDataIOTestSuite, mitkGIFCooc2TestSuite, mitkGIFCurvatureStatisticTestSuite, mitkGIFFirstOrderHistogramStatisticsTestSuite, mitkGIFFirstOrderNumericStatisticsTestSuite, mitkGIFFirstOrderStatisticsTestSuite, mitkGIFGreyLevelDistanceZoneTestSuite, mitkGIFGreyLevelSizeZoneTestSuite, mitkGIFImageDescriptionFeaturesTestSuite, mitkGIFIntensityVolumeHistogramTestSuite, mitkGIFLocalIntensityTestSuite, mitkGIFNeighbourhoodGreyToneDifferenceFeaturesTestSuite, mitkGIFNeighbouringGreyLevelDependenceFeatureTestSuite, mitkGIFVolumetricDensityStatisticsTestSuite, mitkGIFVolumetricStatisticsTestSuite, mitkGlobalFeaturesTestSuite, mitkGlobalFeaturesTestSuite, mitkImageCastTestSuite, mitkImageDataItemTestSuite, mitkImageEqualTestSuite, mitkImageGeneratorTestSuite, mitkImageToItkTestSuite, mitkImageToSurfaceFilterTestSuite, mitkImageToUnstructuredGridFilterTestSuite, mitkInteractionEventTestSuite, mitkIOUtilTestSuite, mitkItkImageIOTestSuite, mitkLabelAnnotation3DTestSuite, mitkLayoutAnnotationRendererTestSuite, mitkLevelWindowManagerCppUnitTestSuite, mitkLibSVMClassifierTestSuite, mitkLineTestSuite, mitkLogoAnnotationTestSuite, mitkLookupTableTestSuite, mitkManualPlacementAnnotationRendererTestSuite, mitkMatrixTypeConversionTestSuite, mitkMCThreadHandlerTestSuite, mitkMcxyzXmlTestSuite, mitkNodePredicateDataPropertyTestSuite, mitkNodePredicateFunctionTestSuite, mitkNodePredicateGeometryTestSuite, mitkPAFilterServiceTestSuite, mitkPhotoacoustic3dVolumeTestSuite, mitkPhotoacousticComposedVolumeTestSuite, mitkPhotoacousticIOTestSuite, mitkPhotoacousticMotionCorrectionFilterTestSuite, mitkPhotoacousticNoiseGeneratorTestSuite, mitkPhotoacousticTissueGeneratorTestSuite, mitkPhotoacousticVectorTestSuite, mitkPhotoacousticVesselMeanderStrategyTestSuite, mitkPhotoacousticVesselTestSuite, mitkPhotoacousticVesselTreeTestSuite, mitkPhotoacousticVolumeTestSuite, mitkPixelTypeTestSuite, mitkPlanarFigureInteractionTestSuite, mitkPlaneGeometryTestSuite, mitkPointSetDataInteractorTestSuite, mitkPointSetEqualTestSuite, mitkPointSetLocaleTestSuite, mitkPointSetOnEmptyTestSuite, mitkPointSetPointOperationsTestSuite, mitkPointSetTestSuite, mitkPointTypeConversionTestSuite, mitkPreferenceListReaderOptionsFunctorTestSuite, mitkProgressBarTestSuite, mitkPropertyAliasesTestSuite, mitkPropertyCalculatorTestSuite, mitkPropertyDescriptionsTestSuite, mitkPropertyExtensionsTestSuite, mitkPropertyFiltersTestSuite, mitkPropertyKeyPathTestSuite, mitkPropertyNameHelperTestSuite, mitkPropertyPersistenceInfoTestSuite, mitkPropertyPersistenceTestSuite, mitkPropertyRelationRuleBaseTestSuite, mitkPropertyRelationsTestSuite, mitkPropertyTestSuite, mitkProportionalTimeGeometryTestSuite, mitkRawImageFileReaderTestSuite, mitkRESTClientTestSuite, mitkRESTServerTestSuite, mitkRTDoseReaderServiceTestSuite, mitkRTPlanReaderServiceTestSuite, mitkRTPlanReaderTestSuite, mitkRTStructureSetReaderServiceTestSuite, mitkScaleLegendAnnotationTestSuite, mitkSceneIOTest2Suite, mitkSemanticRelationsTestSuite, mitkSimulationBatchGeneratorTestSuite, mitkSlicedVolumeGeneratorTestSuite, mitkSliceNavigationControllerTestSuite, mitkSmoothedClassProbabilitesTestSuite, mitkSmoothedClassProbabilitesTestSuite, mitkSourceImageRelationRuleTestSuite, mitkSpectralUnmixingTestSuite, mitkSplineVtkMapper3DTestSuite, mitkSTLFileReaderTestSuite, mitkSurfaceEqualTestSuite, mitkSurfaceTestSuite, mitkSurfaceToImageFilterTestSuite, mitkSurfaceVtkMapper2D3DTestSuite, mitkSurfaceVtkMapper2DTestSuite, mitkTemporoSpatialStringPropertyTestSuite, mitkTextAnnotation2DTestSuite, mitkTextAnnotation3DTestSuite, mitkTinyXMLTestSuite, mitkUIDGeneratorTestSuite, mitkUnstructuredGridClusteringFilterTestSuite, mitkUnstructuredGridToUnstructuredGridFilterTestSuite, mitkVectorPropertySerializerTestSuite, mitkVectorPropertyTestSuite, mitkVectorTestSuite, mitkVectorTypeConversionTestSuite, mitkVigraRandomForestTestSuite, mitkWeakPointerTestSuite, and QmitkDataStorageListModelTestSuite.

Collaboration diagram for mitk::TestFixture:

Protected Member Functions

std::vector< std::string > GetTestParameter () const
 Get parameters for this test fixture. More...
 

Static Protected Member Functions

static std::string GetTestDataFilePath (const std::string &testData)
 Get the absolute path for test data. More...
 

Detailed Description

Test fixture for parameterized tests.

This class is a drop-in replacement for CppUnit::TextFixture and enables test methods to access individual parameters. You can also invoke one method multiple times with different parameters.

The following simple example creates a single test without custom parameters:

class MySimpleTestSuite : public mitk::TestFixture
{
CPPUNIT_TEST_SUITE(MySimpleTestSuite);
MITK_TEST(FivePlusFiveTest);
CPPUNIT_TEST_SUITE_END();
public:
void FivePlusFiveTest()
{
CPPUNIT_ASSERT(5+5 == 10);
}
};
MITK_TEST_SUITE_REGISTRATION(MySimpleTestSuite)

The following example creates a test class containing only one test method, but the associated test suite contains three tests, using different parameters for each call of the same method. Use the macro MITK_PARAMETERIZED_TEST_1 only if you know what you are doing. If you are not sure, use MITK_TEST instead.

class MyTestSuite : public mitk::TestFixture
{
CPPUNIT_TEST_SUITE(MyTestSuite);
MITK_PARAMETERIZED_TEST_1(TestSomething, "One");
MITK_PARAMETERIZED_TEST_1(TestSomething, "Two");
MITK_PARAMETERIZED_TEST_1(TestSomething, "Three");
CPPUNIT_TEST_SUITE_END();
public:
void TestSomething()
{
std::vector<std::string> parameter = GetTestParameter();
CPPUNIT_ASSERT(parameter.size() == 1);
std::string testParam = parameter[0];
MITK_INFO << "Parameter: " << testParam;
}
};
See also
MITK_PARAMETERIZED_TEST
MITK_PARAMETERIZED_TEST_1

Definition at line 86 of file mitkTestFixture.h.

Member Function Documentation

◆ GetTestDataFilePath()

static std::string mitk::TestFixture::GetTestDataFilePath ( const std::string &  testData)
inlinestaticprotected

Get the absolute path for test data.

Parameters
testDataThe realative path in the MITK test data repository.
Returns
The absolute path for the test data.

Definition at line 107 of file mitkTestFixture.h.

References MITK_DATA_DIR.

Referenced by CompareSurfacePointPositions(), createTextAnnotationWithLayouter(), GenerateGradientWithDimXImage(), and GetEmptyTestImageWithGeometry().

◆ GetTestParameter()

std::vector<std::string> mitk::TestFixture::GetTestParameter ( ) const
inlineprotected

Get parameters for this test fixture.

This method can be called in tests added via the MITK_PARAMETERIZED_TEST macro or one of its variants.

Returns
The list of std::string parameters passed to previous calls of the MITK_PARAMETERIZED_TEST macro or one of its variants.

Definition at line 99 of file mitkTestFixture.h.


The documentation for this class was generated from the following file: