classdef TestDiagnosticSaverPlugin < matlab.unittest.plugins.TestRunnerPlugin
properties
TestDiagnosticData
end
methods (Access = protected)
function runTestSuite(plugin, pluginData)
plugin.TestDiagnosticData = [];
runTestSuite@...
matlab.unittest.plugins.TestRunnerPlugin(plugin, pluginData);
end
function testCase = createTestMethodInstance(plugin, pluginData)
testCase = createTestMethodInstance@...
matlab.unittest.plugins.TestRunnerPlugin(plugin, pluginData);
testName = pluginData.Name;
testCase.addlistener('VerificationFailed', ...
@(~,event)plugin.storeTestDiagnosticsData(event,pluginData.Name));
end
end
methods (Access = private)
function storeTestDiagnosticsData(plugin,eventData,name,failureType)
s.Name = {name};
s.TestDiagnostics = eventData.TestDiagnosticResult;
plugin.TestDiagnosticData = [plugin.TestDiagnosticData; struct2table(s)];
end
end
end
Best Answer