Main Content

retrieveFrom

Class: matlab.unittest.plugins.Parallelizable
Package: matlab.unittest.plugins

Retrieve data stored for group of tests

Since R2019b

Description

example

data = retrieveFrom(plugin,communicationBuffer) retrieves the data collected by plugin from the buffer communicationBuffer. The data must be stored in the buffer by a MATLAB® worker while running a group of tests.

To run tests in parallel, the testing framework divides the original TestSuite array into separate groups and assigns them to workers on the current parallel pool (requires Parallel Computing Toolbox™). To enable the MATLAB client to retrieve data from the workers, invoke retrieveFrom within the scope of the reportFinalizedSuite method of TestRunnerPlugin. The workers must store their data by invoking the storeIn method within the scope of runTestSuite.

Input Arguments

expand all

Plugin object, specified as an instance of the plugin class that subclasses the matlab.unittest.plugins.Parallelizable interface.

Buffer from which the client retrieves data, specified as an instance of the matlab.unittest.plugins.plugindata.CommunicationBuffer class. communicationBuffer represents a property of the matlab.unittest.plugins.plugindata.FinalizedSuitePluginData instance that is passed to the reportFinalizedSuite method.

Output Arguments

expand all

Data retrieved from the buffer, returned as a scalar or an array of objects.

Attributes

Accessprotected
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Invoke the retrieveFrom method in the plugin class to retrieve the number of elements in the finalized TestSuite array.

classdef ExamplePlugin < ...
        matlab.unittest.plugins.TestRunnerPlugin & ...
        matlab.unittest.plugins.Parallelizable
    
    methods (Access = protected)
        function runTestSuite(plugin, pluginData) 
            
            % Display and store running TestSuite size
            suiteSize = numel(pluginData.TestSuite);
            fprintf('### Running %d tests\n', suiteSize)
            plugin.storeIn(pluginData.CommunicationBuffer, suiteSize);

            runTestSuite@matlab.unittest.plugins.TestRunnerPlugin(...
                plugin, pluginData);
        end
        
        function reportFinalizedSuite(plugin, pluginData)
            
            % Retrieve and display finalized TestSuite size
            suiteSize = plugin.retrieveFrom(pluginData.CommunicationBuffer);
            fprintf('### Finished running %d tests\n', suiteSize)

            reportFinalizedSuite@matlab.unittest.plugins.TestRunnerPlugin(...
                plugin, pluginData);
        end
    end
    
end

Version History

Introduced in R2019b