How to pass additional data to testresults of unittest inside testmethod of matlab.unittest.TestCase in 2019b

8 visualizzazioni (ultimi 30 giorni)
Hello I`m searching for the best way adding data to test results. The aim is to add additional information to the results of a testmethod in a way that i can apply easily further evaluation on all testresult data. For example Im testing with image_data in a testcase class TestMyImageData < matlab.unittest.TestCase and I'm using the factory method to create the suite = matlab.unittest.TestSuite.fromClass(?TestMyImageData, 'ExternalParameters',param). While param holds various images data. After testrun I would like to be able to make further operations on testresult data:
create_my_figure_for_analysis([testresults.Details])
Im not interested in any figure creation and logging to files while testrun. I would like to decide afterwards what I plot or analyze based on the data I specified to go with the testresult of a testmethod. Maybe something like the following:
function test_my_stuff(testCase)
...
testCase.addToResults('Names',ImageName,'Difference',difference)
testCase.verifyLessThan(difference, MY_EXPECTED_DIFF)
end
...
results = runner.run()
results(1).Details.Difference

Risposta accettata

Andy Campbell
Andy Campbell il 3 Nov 2020
Hi Florian,
The ability to write a plugin that can append to the test result details was added in R2020a and is documented here. In this case, since you are adding the data from within the test method itself, you can add the data as a Diagnostic and log the data. Then the plugin can listen to the DiagnosticLogged event and add the logged data to your test result. Hope that helps!
Andy

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by