Class ClassCoverage

  • All Implemented Interfaces:
    AggregatedCoverage

    public class ClassCoverage
    extends java.lang.Object
    implements AggregatedCoverage
    Test class coverage model. The class coverage is an aggregation of all test method coverages.
    • Constructor Detail

      • ClassCoverage

        public ClassCoverage()
    • Method Detail

      • addCoveredElement

        public void addCoveredElement​(java.lang.String testName,
                                      CoveredElement coveredElement)
        Adds a covered element to the test method coverage.
        Parameters:
        testName -
        coveredElement -
      • endCoveredElement

        public void endCoveredElement​(java.lang.String currentTestMethodName,
                                      CoveredElement coveredElement)
        Mark a covered element execution as ended.
        Parameters:
        currentTestMethodName -
        coveredElement -
      • getTestMethodCoverage

        public MethodCoverage getTestMethodCoverage​(java.lang.String testName)
        Retrieves a test methods coverage.
        Parameters:
        testName - The name of the test method.
        Returns:
      • getTestMethodCoverage

        public java.util.Map<java.lang.String,​MethodCoverage> getTestMethodCoverage()
        Retrieves all method coverage.
        Returns:
      • addTestMethodCoverage

        public void addTestMethodCoverage​(java.lang.String testName,
                                          MethodCoverage testCoverage)
        Add a test method coverage to the class coverage.
        Parameters:
        testName -
        testCoverage -
      • getCoveragePercentage

        public double getCoveragePercentage()
        Retrieves the class coverage percentage. All covered test methods' elements are aggregated and checked against the process definition elements.
        Specified by:
        getCoveragePercentage in interface AggregatedCoverage
        Returns:
        The coverage percentage.
      • getCoveragePercentage

        public double getCoveragePercentage​(java.lang.String processDefinitionKey)
        Retrieves the class coverage percentage for the given process definition key. All covered test methods' elements are aggregated and checked against the process definition elements.
        Specified by:
        getCoveragePercentage in interface AggregatedCoverage
        Parameters:
        processDefinitionKey -
        Returns:
        The coverage percentage.
      • getCoveredFlowNodes

        public java.util.Set<CoveredFlowNode> getCoveredFlowNodes()
        Retrieves the covered flow nodes. Flow nodes with the same element ID but different process definition keys are retained.
        Returns:
        A set of covered flow nodes.
      • getCoveredFlowNodeIds

        public java.util.Set<java.lang.String> getCoveredFlowNodeIds​(java.lang.String processDefinitionKey)
        Retrieves a set of covered flow node IDs for the given process definition key.
        Specified by:
        getCoveredFlowNodeIds in interface AggregatedCoverage
        Returns:
      • getCoveredSequenceFlows

        public java.util.Set<CoveredSequenceFlow> getCoveredSequenceFlows()
        Retrieves the covered sequence flows. Sequence flows with the same element ID but different process definition keys are retained.
        Returns:
        A set of covered flow nodes.
      • getCoveredSequenceFlowIds

        public java.util.Set<java.lang.String> getCoveredSequenceFlowIds​(java.lang.String processDefinitionKey)
        Retrieves a set of covered sequence flow IDs for the given process definition key.
        Specified by:
        getCoveredSequenceFlowIds in interface AggregatedCoverage
        Returns:
      • getCoveredSequenceFlows

        public java.util.Set<CoveredSequenceFlow> getCoveredSequenceFlows​(java.lang.String processDefinitionKey)
        Retrieves a set of covered sequence flows for the given process definition key.
        Specified by:
        getCoveredSequenceFlows in interface AggregatedCoverage
        Parameters:
        processDefinitionKey -
        Returns:
      • getProcessDefinitions

        public java.util.Set<org.camunda.bpm.engine.repository.ProcessDefinition> getProcessDefinitions()
        Retrieves the process definitions of the coverage test. Since there are multiple deployments (one for each test method) the first set of process definitions found is return.
        Specified by:
        getProcessDefinitions in interface AggregatedCoverage
        Returns:
      • getAnyMethodCoverage

        protected MethodCoverage getAnyMethodCoverage()
        Retrieves the first method coverage found.
        Returns:
      • assertAllDeploymentsEqual

        public void assertAllDeploymentsEqual()
        Asserts if all method deployments are equal. (BPMNs with the same business keys)