diff --git a/+misc/runSingleTest.m b/+misc/runSingleTest.m new file mode 100644 index 0000000000000000000000000000000000000000..685ba154fbb33bebcbb6b5a8681c486f2981578c --- /dev/null +++ b/+misc/runSingleTest.m @@ -0,0 +1,13 @@ +function runSingleTest(testSuite, testName) +%RUNSINGLETEST runs a single test of a test file +% runSingleTest(testSuite, testName) runs the testfunction with the name +% 'testName' of the 'testSuite'. A testSuite can be produced by +% matlab.unittest.TestSuite.from*... or if the tests are defined in a +% file, this file can be directly used as testSuite. +% Example: +% testSuite = unittests.quantity.testSymbolic +% testName = 'testCat' +% runSingletest(testSuite, testName) +testSuite(strcmp({testSuite.ProcedureName}, testName)).run +end + diff --git a/+unittests/readme.md b/+unittests/readme.md index 346d0b9808e15c016b6b49b5368254cefa31c1d4..06b3131cfcb23c3b0f7cfc339a6ef2b5e6beaf08 100644 --- a/+unittests/readme.md +++ b/+unittests/readme.md @@ -3,6 +3,9 @@ To run multiple unittests in packages use: If you want to run only the tests for a subpackage, you can use the code: result = run(matlab.unittest.TestSuite.fromPackage('unittests.<subpackage name>', 'IncludingSubpackages', true)) +If you want to run only a single test of a subpackage, you can use the helper function + misc.runSingleTest(testSuite, testName) + Some tests need reference results or save data locally in order to improve speed. This is usually done in a setupOnce() function. Therefore, calling unittests for the first time, might take a lot longer then afterwards.