Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions
gmx::test::AbstractTrajectoryAnalysisModuleTestFixture Class Referenceabstract

#include <gromacs/trajectoryanalysis/tests/moduletest.h>

+ Inheritance diagram for gmx::test::AbstractTrajectoryAnalysisModuleTestFixture:
+ Collaboration diagram for gmx::test::AbstractTrajectoryAnalysisModuleTestFixture:

Description

Test fixture for trajectory analysis modules.

This class implements common logic for all tests for trajectory analysis modules. The tests simply need to specify the type of the module to test, input files and any additional options, names of datasets to test (if not all), and possible output files to explicitly test by calling the different methods in this class. runTest() then runs the specified module with the given options and performs all the requested tests against reference data.

Tests should prefer to test the underlying data sets instead of string comparison on the output files using setOutputFile().

The actual module to be tested is constructed in the pure virtual createModule() method, which should be implemented in a subclass. Typically, the TrajectoryAnalysisModuleTestFixture template can be used.

Any method in this class may throw std::bad_alloc if out of memory.

Todo:
Adding facilities to AnalysisData to check whether there are any output modules attached to the data object (directly or indirectly), marking the mocks as output modules, and using these checks in the tools instead of or in addition to the output file presence would be a superior. Also, the full file names should be deducible from the options.

Public Member Functions

void setTopology (const char *filename)
 Sets the topology file to use for the test. More...
 
void setTrajectory (const char *filename)
 Sets the trajectory file to use for the test. More...
 
void includeDataset (const char *name)
 Includes only specified dataset for the test. More...
 
void excludeDataset (const char *name)
 Excludes specified dataset from the test. More...
 
void setDatasetTolerance (const char *name, const FloatingPointTolerance &tolerance)
 Sets a custom tolerance for checking a dataset. More...
 
void runTest (const CommandLine &args)
 Runs the analysis module with the given additional options. More...
 
- Public Member Functions inherited from gmx::test::CommandLineTestBase
void setInputFile (const char *option, const char *filename)
 Sets an input file. More...
 
void setInputFile (const char *option, const std::string &filename)
 Sets an input file. More...
 
void setModifiableInputFile (const char *option, const char *filename)
 Sets an input file that may be modified. The file is copied to a temporary file, which is used as the test input. More...
 
void setModifiableInputFile (const char *option, const std::string &filename)
 Sets an input file that may be modified. The file is copied to a temporary file, which is used as the test input. More...
 
void setInputFileContents (const char *option, const char *extension, const std::string &contents)
 Generates and sets an input file. More...
 
void setInputFileContents (const char *option, const char *extension, const ArrayRef< const char *const > &contents)
 Generates and sets an input file. More...
 
void setOutputFile (const char *option, const char *filename, const ITextBlockMatcherSettings &matcher)
 Sets an output file parameter and adds it to the set of tested files. More...
 
void setOutputFile (const char *option, const char *filename, const IFileMatcherSettings &matcher)
 Sets an output file parameter and adds it to the set of tested files. More...
 
void setInputAndOutputFile (const char *option, const char *filename, const ITextBlockMatcherSettings &matcher)
 Sets a file parameter that is used for input and modified as output. The input file is copied to a temporary file that is used as input and can be modified.
 
void setInputAndOutputFile (const char *option, const char *filename, const IFileMatcherSettings &matcher)
 Sets a file parameter that is used for input and modified as output. The input file is copied to a temporary file that is used as input and can be modified. More...
 
CommandLinecommandLine ()
 Returns the internal CommandLine object used to construct the command line for the test. More...
 
TestFileManagerfileManager ()
 Returns the internal TestFileManager object used to manage the files. More...
 
TestReferenceChecker rootChecker ()
 Returns the root reference data checker. More...
 
void setDefaultTolerance (const FloatingPointTolerance &tolerance)
 Sets the tolerance for floating-point comparisons. More...
 
void testWriteHelp (ICommandLineModule *module)
 Checks the output of writeHelp() against reference data.
 
void checkOutputFiles ()
 Checks output files added with setOutputFile() against reference data. More...
 

Protected Member Functions

virtual
TrajectoryAnalysisModulePointer 
createModule ()=0
 Constructs the analysis module to be tested.
 

Member Function Documentation

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::excludeDataset ( const char *  name)

Excludes specified dataset from the test.

Parameters
[in]nameName of dataset to exclude.

name should be one of the names registered for the tested module using TrajectoryAnalysisModule::registerBasicDataset() or TrajectoryAnalysisModule::registerAnalysisDataset().

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::includeDataset ( const char *  name)

Includes only specified dataset for the test.

Parameters
[in]nameName of dataset to include.

If this method is not called, all datasets are tested by default. If called once, only the specified dataset is tested. If called more than once, also the additional datasets are tested.

name should be one of the names registered for the tested module using TrajectoryAnalysisModule::registerBasicDataset() or TrajectoryAnalysisModule::registerAnalysisDataset().

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::runTest ( const CommandLine args)

Runs the analysis module with the given additional options.

Parameters
[in]argsOptions to provide to the module.

args should be formatted as command-line options, and contain the name of the module as the first argument (the latter requirement is for clarity only). They are passed to the module in addition to those specified using other methods in this class.

All other methods should be called before calling this method.

Exceptions thrown by the module are caught by this method.

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::setDatasetTolerance ( const char *  name,
const FloatingPointTolerance tolerance 
)

Sets a custom tolerance for checking a dataset.

Parameters
[in]nameName of dataset to set the tolerance for.
[in]toleranceTolerance used when verifying the data.

name should be one of the names registered for the tested module using TrajectoryAnalysisModule::registerBasicDataset() or TrajectoryAnalysisModule::registerAnalysisDataset().

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::setTopology ( const char *  filename)

Sets the topology file to use for the test.

Parameters
[in]filenameName of input topology file.

filename is interpreted relative to the test input data directory, see getTestDataPath().

Must be called at most once. Either this method or setTrajectory() must be called before runTest().

void gmx::test::AbstractTrajectoryAnalysisModuleTestFixture::setTrajectory ( const char *  filename)

Sets the trajectory file to use for the test.

Parameters
[in]filenameName of input trajectory file.

filename is interpreted relative to the test input data directory, see getTestDataPath().

Must be called at most once. Either this method or setTopology() must be called before runTest().


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