Main Content

matlab.unittest.constraints.IsFolder class

Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.BooleanConstraint

Constraint specifying value points to folder

Construction

IsFolder creates a constraint specifying that a value is a string scalar or character vector that points to an existing folder. The constraint is satisfied if the value is an absolute or relative path to an existing folder.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

Examples

collapse all

Create a test case for interactive testing.

import matlab.unittest.TestCase;
import matlab.unittest.constraints.IsFolder;

testCase = TestCase.forInteractiveUse;

Test if myFolder is an existing folder in your current working folder. This example assumes that the folder does not exist and the test fails.

act = 'myFolder';
testCase.verifyThat(act,IsFolder)
Interactive verification failed.

---------------------
Framework Diagnostic:
---------------------
IsFolder failed.
--> Value does not point to an existing folder.
--> Current folder during evaluation:
        'C:\work'

Actual char:
    myFolder

In your current working folder, create a folder myFolder.

mkdir myFolder

Verify that myFolder is an existing folder in your current working folder.

act = 'myFolder';
testCase.verifyThat(act,IsFolder)
Interactive verification passed.

Create a test case for interactive testing.

import matlab.unittest.TestCase;
import matlab.unittest.constraints.IsFolder;

testCase = TestCase.forInteractiveUse;

Verify that nonexistentFolder is not an existing folder in your current working folder. This example assumes that the folder does not exist and the test passes.

act = 'nonexistentFolder';
testCase.verifyThat(act,~IsFolder)
Interactive verification passed.
Introduced in R2018a