Main Content


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

Store data collected for group of tests



storeIn(plugin,communicationBuffer,data) stores the data collected by plugin in the buffer communicationBuffer. The data is collected 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 workers to store their data, invoke storeIn within the scope of the runTestSuite method of TestRunnerPlugin. The MATLAB client can retrieve the stored data by invoking the retrieveFrom method within the scope of reportFinalizedSuite.


Each new call to storeIn overwrites the previously stored data. Therefore, write to the buffer only one time within the scope of the runTestSuite method. If you need to store several data items, include them all in data using an appropriate data type.

Input Arguments

expand all

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

Buffer in which the worker stores data, specified as an instance of the matlab.unittest.plugins.plugindata.CommunicationBuffer class. communicationBuffer represents a property of the matlab.unittest.plugins.plugindata.TestSuiteRunPluginData instance that is passed to the runTestSuite method.

Data to store in the buffer, specified as a scalar or an array of objects. For example, you can specify data as a numeric scalar, string array, cell array, structure, or class object.

Parallel Computing Toolbox serializes data on the worker side, saves it in communicationBuffer, and deserializes it on the client side. data must properly facilitate being saved and loaded. For more information, see Save and Load Process for Objects.



To learn about attributes of methods, see Method Attributes.


expand all

Invoke the storeIn method in the plugin class to store the number of elements in the running TestSuite array.

classdef ExamplePlugin < ...
        matlab.unittest.plugins.TestRunnerPlugin & ...
    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);

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

                plugin, pluginData);
Introduced in R2019b