Package org.camunda.community.bpmndt.api
Class AbstractTestCase<T extends AbstractTestCase<?>>
java.lang.Object
org.camunda.community.bpmndt.api.AbstractTestCase<T>
- Type Parameters:
T- The generated test case type.
- Direct Known Subclasses:
AbstractJUnit5TestCase
Abstract superclass for test cases.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TestCaseInstanceprotected Class<?> The related test class - must be provided by the concrete implementation.protected MethodThe test method, which will be executed - must be provided by the concrete implementation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPerforms the teardown for a test case execution.protected voidPerforms the setup for a test case execution by creating aTestCaseInstanceand deploying the related BPMN resources.protected org.camunda.bpm.engine.ProcessEngineBuilds the process engine, used to execute the test case.Creates a new executor, used to specify variables, business key and/or mocks that are considered during test case execution.protected abstract voidexecute(org.camunda.bpm.engine.runtime.ProcessInstance pi) Executes the test case.protected InputStreamReturns an input stream that provides the BPMN resource with the process definition to be tested - either this method orgetBpmnResourceName()must be overridden!protected StringReturns the name of the BPMN resource, that provides the process definition to be tested - either this method orgetBpmnResource()must be overridden!Returns the ID of the process definition deployment.abstract StringgetEnd()Returns the ID of the test case's end activity.abstract StringReturns the key of the process definition that is tested.org.camunda.bpm.engine.ProcessEngineReturns the process engine, used to execute the test case.protected List<org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin> Provides customProcessEnginePlugins to be registered when the process engine is built.abstract StringgetStart()Returns the ID of the test case's start activity.protected booleanDetermines if the test case's end activity ends the process or not.protected booleanDetermines if Spring based testing is enabled or not.withTenantId(String tenantId) Sets the tenant ID to be used for the automatic process definition deployment.
-
Field Details
-
testClass
The related test class - must be provided by the concrete implementation. -
testMethod
The test method, which will be executed - must be provided by the concrete implementation. -
instance
-
-
Constructor Details
-
AbstractTestCase
public AbstractTestCase()
-
-
Method Details
-
beforeEach
protected void beforeEach()Performs the setup for a test case execution by creating aTestCaseInstanceand deploying the related BPMN resources. This method must be invoked before each test! -
afterEach
protected void afterEach()Performs the teardown for a test case execution. This method must be invoked after each test! -
buildProcessEngine
protected org.camunda.bpm.engine.ProcessEngine buildProcessEngine()Builds the process engine, used to execute the test case. The method registers customProcessEnginePlugins as well as theBpmndtProcessEnginePlugin, which is required to configure a conform process engine.- Returns:
- The newly created process engine.
-
createExecutor
Creates a new executor, used to specify variables, business key and/or mocks that are considered during test case execution. After the specification,TestCaseExecutor.execute()is called to create a newProcessInstanceand execute the test case.- Returns:
- The newly created executor.
-
execute
protected abstract void execute(org.camunda.bpm.engine.runtime.ProcessInstance pi) Executes the test case.- Parameters:
pi- A process instance, created especially for the test case.
-
getBpmnResource
Returns an input stream that provides the BPMN resource with the process definition to be tested - either this method orgetBpmnResourceName()must be overridden!- Returns:
- The BPMN resource as stream.
-
getBpmnResourceName
Returns the name of the BPMN resource, that provides the process definition to be tested - either this method orgetBpmnResource()must be overridden!- Returns:
- The BPMN resource name, within
src/main/resources.
-
getDeploymentId
Returns the ID of the process definition deployment.- Returns:
- The deployment ID.
-
getEnd
Returns the ID of the test case's end activity.- Returns:
- The end activity ID.
-
getProcessDefinitionKey
Returns the key of the process definition that is tested.- Returns:
- The process definition key.
-
getProcessEngine
public org.camunda.bpm.engine.ProcessEngine getProcessEngine()Returns the process engine, used to execute the test case.- Returns:
- The process engine.
-
getProcessEnginePlugins
Provides customProcessEnginePlugins to be registered when the process engine is built. By default, this method return an empty list. It can be overridden by any extending class.- Returns:
- A list of process engine plugins to register.
- See Also:
-
getStart
Returns the ID of the test case's start activity.- Returns:
- The start activity ID.
-
isSpringEnabled
protected boolean isSpringEnabled()Determines if Spring based testing is enabled or not. This method returnsfalse, if not overridden.- Returns:
true, if the testing is Spring based. Otherwisefalse.
-
isProcessEnd
protected boolean isProcessEnd()Determines if the test case's end activity ends the process or not. This is the case if the activity is an end event and if the activity's parent scope is the process. This method returnstrue, if not overridden.- Returns:
true, if the test case's end activity ends the process. Otherwisefalse.
-
withTenantId
Sets the tenant ID to be used for the automatic process definition deployment.- Parameters:
tenantId- A specific tenant ID.- Returns:
- The test case.
-