Main Content


Class: matlab.unittest.plugins.Parallelizable
Namespace: matlab.unittest.plugins

Store data collected for group of tests

Since R2019b



storeIn(plugin,buffer,data) stores the data collected using the plugin in the specified communication buffer. The data must be stored in buffer by a MATLAB® worker while running a group of tests.

To run tests in parallel, the testing framework divides the original test suite into 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. 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, 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 a matlab.unittest.plugins.plugindata.CommunicationBuffer object. buffer represents a property of the TestSuiteRunPluginData instance that is passed to the runTestSuite method.

Data to store in the buffer, specified as a value of any data type. For example, you can specify a numeric scalar, string array, structure, or MATLAB object.

Parallel Computing Toolbox serializes data on the worker side, stores it in buffer, and deserializes it on the client side. Therefore, data must support the save and load operations. For more information, see Save and Load Process for Objects.



To learn about attributes of methods, see Method Attributes.


expand all

Create a parallelizable plugin that displays the number of running and finalized tests in existing test groups. To store the number of tests in a running group, invoke the storeIn method within the runTestSuite method.

classdef ExamplePlugin < ...
        matlab.unittest.plugins.TestRunnerPlugin & ...
    methods (Access = protected)
        function runTestSuite(plugin,pluginData) 
            % Display and store running test suite size
            suiteSize = numel(pluginData.TestSuite);
            fprintf("### Running %d test(s)\n",suiteSize)
            % Invoke the superclass method
            runTestSuite@ ...
        function reportFinalizedSuite(plugin,pluginData)
            % Retrieve and display finalized test suite size
            suiteSize = plugin.retrieveFrom(pluginData.CommunicationBuffer);
            fprintf("### Finished running %d test(s)\n",suiteSize)

            % Invoke the superclass method
            reportFinalizedSuite@ ...

Version History

Introduced in R2019b