matlab.unittest.fixtures.WorkingFolderFixture Class
R2026bNamespace: matlab.unittest.fixtures
Superclasses: matlab.unittest.fixtures.Fixture
Fixture for creating and switching to temporary folder
Description
The matlab.unittest.fixtures.WorkingFolderFixture class provides a fixture for creating a temporary folder
and setting that folder as the current (working) folder. Using this fixture, a test or the
software under test can modify the contents of the folder—for example, by creating
files—without affecting the source or test folder structure.
When the testing framework sets up the fixture, the fixture adds the current folder to the path, creates a temporary folder, and changes the current folder to the temporary folder. When the framework tears down the fixture, the fixture deletes the temporary folder and its contents by default, and then restores the current folder to the original working folder.
The matlab.unittest.fixtures.WorkingFolderFixture class is a handle class.
Creation
Description
fixture = matlab.unittest.fixtures.WorkingFolderFixture
constructs a fixture for creating a temporary folder and setting that folder as the
current folder.
fixture = matlab.unittest.fixtures.WorkingFolderFixture(
specifies options using one or more name-value arguments. For example, Name=Value)fixture =
matlab.unittest.fixtures.WorkingFolderFixture(PreservingOnFailure=true)
constructs a fixture that does not delete the temporary folder in the event of a
failure.
Name-Value Arguments
Properties
Examples
Tips
Both the
WorkingFolderFixtureandTemporaryFolderFixtureclasses create a fixture that results in a temporary folder. However, the fixture created withWorkingFolderFixturealso sets the temporary folder as the current folder.
Version History
Introduced in R2016a