How to pass additional data to testresults of unittest inside testmethod of matlab.unittest.TestCase in 2019b
7 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Andy Campbell
2020-11-3
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Run Unit Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!