Simple C++ test framework based on Qt, but not on QTest.
The framework consists of one header only and needs no compilation.
Class tests are created by using the TEST_CLASS macro. Test methods are defining using the TEST_METHOD macro:
SomeClass_Test.cpp:
#include "TestFramework.h"
TEST_CLASS(SomeClass_Test)
{
private:
TEST_METHOD(TestMethod1)
{
I_EQUAL(1+1, 2)
}
TEST_METHOD(TestMethod2)
{
IS_FALSE(1+1==3)
}
}
The all test classes are compiled into one app and executed by this simple call:
main.cpp:
#include "TestFramework.h"
int main(int argc, char *argv[])
{
return TFW::run(argc, argv);
}
The test executable can be invoked with these parameters:
-sFilter string for test cases. Tests that contain the string (case-sensitive) in the test class name or test method name are executed.-lTest case list file. Tests that are contained in the given text file are executed.-hPrints a short help.
IS_TRUE(expression)Checks that the expression evaluates to true.IS_FALSE(expression)Checks that the expression evaluates to false.I_EQUAL(actual, expected)Integer equality check.F_EQUAL(actual, expected)Float equality check (with default accuracy).F_EQUAL2(actual, expected, delta)Float equality check (with custom accuracy).S_EQUAL(actual, expected)String equality check.X_EQUAL(actual, expected)General equality check.IS_THROWN(exception, expression)Checks that the exception type is thrown by the expression.
##File handling macros
EXECUTE(toolname, arguments)Executes a tool from the same folder and checks the error code. Use lastLogFile() to get the log file of the last call.EXECUTE_FAIL(toolname, arguments)Executes a tool from the same folder and ignores the error code. Use lastLogFile() to get the log file of the last call.TESTDATA(filename)Locates test data relative to the test source file.COMPARE_FILES(actual, expected)File equality check (gzipped or plain files).COMPARE_FILES_DELTA(actual, expected, delta, delta_is_percentage, separator)File equality check with custom accuracy for numeric values (gzipped or plain files).REMOVE_LINES(filename, regexp)Removes lines that match the given QRegularExpression form a file, e.g. a creation date that changes each time.
##Other macros
SKIP(msg)Skips the current test method, e.g. because required resources are not available.TESTDATA(filename)Locates a test data file, relative the test cpp file it is used in.
#TestFrameworkNGS.h
If you are working with ngs-bits, you can also use the following NGS-specific macros:
SKIP_IF_NO_TEST_NGSD()Skips a test if NGSD test instance is not available.SKIP_IF_NO_PROD_NGSD()Skips a test if NGSD production instance is not available.SKIP_IF_NO_PROD_GENLAB()Skips a test if GenLab production instance is not available.SKIP_IF_NO_HG38_GENOME()Skips a test if the HG38 reference genoe is not available.SKIP_IF_NO_HG19_GENOME()Skips a test if the HG19 reference genoe is not available.VCF_IS_VALID(vcf_file)Checks a hg38 VCF file.VCF_IS_VALID_HG19(vcf_file)Checks a hg19 VCF file.