主要内容

addClassification

R2026b

Add classification to threshold rule

Since R2026b

    Description

    classification = addClassification(rule,Name=Value) adds a classification to the threshold rule rule and returns the new classification as a metric.threshold.Classification object. Each classification defines a compliance category and the condition under which it applies.

    The dashboards display compliance overlays on widgets to show how metric results compare against predefined, shipping thresholds. Each overlay indicates whether results are compliant, non-compliant, a warning, or uncategorized. If the shipping thresholds do not match your project criteria, you can create a custom configuration to define your own compliance criteria as shown in Adjust Dashboard Thresholds to Match Your Testing Criteria.

    A configuration contains threshold sets, each threshold set contains threshold rules, and each rule contains classifications that determine how results are evaluated. The addClassification function lets you extend a threshold rule by adding additional classification levels so you can refine how the dashboard evaluates and displays results on widgets.

    Threshold classifications showing the compliance conditions for the "Tests Linked to Requirements" widget

    example

    Examples

    collapse all

    Add a threshold rule to a custom threshold set and define classifications that specify the compliance criteria.

    Copy a shipping threshold set and add a new threshold rule.

    config = metric.config.Configuration.copyThresholdSet( ...
        SourceThresholdSetId="ReqBasedTesting", ...
        TargetThresholdSetId="MyTestingThresholds");
    
    newRule = addThresholdRule(config, ...
        ThresholdSetId="MyTestingThresholds", ...
        MetricId="modeltesting.TestResultAnalysis[slcomp.TestStatusDistribution]", ...
        ThresholdRuleId="MyNewRuleForTestsNotRun");

    Add a classification for the compliant case. The Statement defines the condition that must evaluate to true for this classification to apply.

    addClassification(newRule, ...
        Category="Compliant", ...
        Statement="Value.NotRun < 5", ...
        Summary="Less than 5 tests not run")

    Add a default classification. An empty Statement indicates that this classification applies when no other classification statement evaluates to true. The default classification must be added last.

    addClassification(newRule, ...
        Category="Uncategorized", ...
        Statement="", ...
        Summary="More than 5 tests not run")

    Verify the classifications on the rule.

    newRule.Classifications(1)
    newRule.Classifications(2)
    ans =
    
      Classification with properties:
    
         Category: Compliant
        Statement: "Value.NotRun < 5"
          Summary: "Less than 5 tests not run"
    
    
    ans =
    
      Classification with properties:
    
         Category: Uncategorized
        Statement: ""
          Summary: "More than 5 tests not run"

    Input Arguments

    collapse all

    Threshold rule to add the classification to, specified as a metric.threshold.ThresholdRule object.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addClassification(newRule,Category="Compliant",Statement="Value.NotRun < 5",Summary="Less than 5 tests not run")

    Compliance category for this classification, specified as "Compliant", "NonCompliant", "Warning", or "Uncategorized". The category determines the compliance overlay shown on the dashboard widget when this classification applies.

    Data Types: string

    Comparison statement that determines when this classification applies, specified as a string scalar. The statement can use relational operators (==, ~=, >, <, >=, <=), logical operators (&&, ||, ~), and arithmetic operators to compare metric result field values against expected values. Function calls are not supported. For example, "Value.NotRun == 0" or "Value.Condition == 100".

    An empty string ("") indicates that this classification is the default case and applies when no other classification statement evaluates to true. A classification with an empty statement must be added last.

    Data Types: string

    Description of the classification outcome, specified as a string scalar. The summary appears in the compliance overlay tooltip in the dashboard.

    Data Types: string

    Output Arguments

    collapse all

    New classification, returned as a metric.threshold.Classification object.

    More About

    collapse all

    Version History

    Introduced in R2026b