camunda-community-hub/camunda-process-test-coverage

Question: How to handle nested inner classes for one bpmn diagramm

arolfes opened this issue · 5 comments

We use in our Kotlin Camunda Project inline classes to structure our ProcessTest

Example

package org.camunda.bpm.extension.process_test_coverage.examples

import org.camunda.bpm.engine.runtime.ProcessInstance
import org.camunda.bpm.engine.test.Deployment
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService
import org.camunda.bpm.extension.process_test_coverage.engine.ProcessCoverageInMemProcessEngineConfiguration
import org.camunda.bpm.extension.process_test_coverage.junit5.ProcessEngineCoverageExtension
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension


class OrderProcessTest {

    companion object {
        @JvmField
        @RegisterExtension
        var extension: ProcessEngineCoverageExtension = ProcessEngineCoverageExtension
            .builder(ProcessCoverageInMemProcessEngineConfiguration())
            .assertClassCoverageAtLeast(1.0).build()
    }

    @Nested
    @Deployment(resources = ["order-process.bpmn"])
    inner class HappyPath {
        @Test
        fun shouldExecuteHappyPath() {
            // TEST something
        }

        @Test
        fun shouldCancelOrder() {
            // TEST something
        }
    }

    @Nested
    @Deployment(resources = ["order-process.bpmn"])
    inner class BpmnErrors {
        @Test
        fun shouldHandleBpmnErrors() {
            // TEST something
        }
    }

    private fun startProcess(): ProcessInstance {
        return runtimeService().startProcessInstanceByKey("order-process")
    }
}

What happens: For each inner class a separate report is generated.
The complete process coverage is 100% but there is no report where you can see that it passed all

Is it possible to create such overall report? If yes, how can it be configured?

If no, is it possible to implement such feature?

Hi there,

Any news on this question?

I'll take a look on that on Friday (at latest).

@rohwerj is the delcaration of the extension correct?

The declaration looks good to me.
The extension might see each inner class as a suite and as such generate a report for each.
I'd have to debug that, but won't be able to do that before 24th of January.

My assumption was more or less correct. The beforeAll method of the extension is called for the parent class and for all nested inner classes. That way the report is not correctly accumulated for the surrounding class.
The PR #165 adds a fix and test for that scenario.