matlab.unittest.diagnostics.FigureDiagnostic Class
Namespace: matlab.unittest.diagnostics
Superclasses: matlab.automation.diagnostics.Diagnostic
Diagnostic to save specified figure
Description
Use the matlab.unittest.diagnostics.FigureDiagnostic class to create a diagnostic for saving a MATLAB® figure during a test run. The saved figure persists after the test run and is
available for post-test inspection.
The matlab.unittest.diagnostics.FigureDiagnostic class is a handle class.
Creation
Description
diag = matlab.unittest.diagnostics.FigureDiagnostic(
creates a diagnostic to save the specified figure. When the testing framework diagnoses
the fig)FigureDiagnostic object, the framework saves fig
as both a FIG file and a PNG file. Each file has a unique name consisting of a prefix
("Figure_", by default), an automatically generated identifier, and
the file extension. An example filename is
Figure_cf95fe7f-5a7c-4310-9c19-16c0c17a969f.png. To view the location
of the saved figure, access the FileArtifact object through the
corresponding TestResult instance.
diag = matlab.unittest.diagnostics.FigureDiagnostic(
specifies additional options using one or more name-value arguments. For example,
fig,Name=Value)diag =
matlab.unittest.diagnostics.FigureDiagnostic(fig,Formats="png") saves the
specified figure as a PNG file only.
Input Arguments
Name-Value Arguments
Properties
Examples
Tips
The location of the saved figure is a folder with a name unique to a test run within the artifacts root folder (specified in the
ArtifactsRootFolderproperty of the test runner). If you run tests interactively, the location is the value returned bytempdir.To determine the path of a saved figure, access the
FileArtifactobject for a particular test result. For example, suppose that the variableresultsrepresents yourTestResultarray. This code determines the location of the generated FIG file for the second test result.results(2).Details.DiagnosticRecord.TestDiagnosticResults.Artifacts(1)
ans = FileArtifact with properties: Name: "Figure_3984704d-b884-44c2-b3ee-7ed10d36e967.fig" Location: "C:\Users\username\AppData\Local\Temp\a1f80242-8f8a-4678-9124-415980432d08" FullPath: "C:\Users\username\AppData\Local\Temp\a1f80242-8f8a-4678-9124-415980432d08\Figure_3984704d-b884-44c2-b3ee-7ed10d36e967.fig"
Version History
Introduced in R2017a