@Ilya_Malyarenko
I have updated spock examples with a “interactive” example: https://github.com/DigitalState/Camunda-Spock-Testing/tree/master/interactive-example
Go into the interactive-example folder and run ./mvnw clean test
the “magic” will be lines like this:
where all of the variables in the active process instance are printed to the console.
you console printout looks like:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running InteractiveSpec
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
May 29, 2018 9:41:33 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [camunda_config/camunda.cfg.xml]
Deployment ID: '1' has been created
Starting the process instance
Process is Active and waiting for user task completion
Process Variables are:
['someVar':'Some String Value', 'json':{"customer":"Kermit"}]
Deployment ID: '1' has been deleted
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.233 sec - in InteractiveSpec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.290 s
[INFO] Finished at: 2018-05-29T21:41:47-04:00
[INFO] Final Memory: 22M/179M
[INFO] ------------------------------------------------------------------------
I have updated the InteractiveSpec.groovy file with simplifications and additional code comments. You don’t need to do much other than duplicate the existing example.
All of the engine services are exposed as per the camunda junit docs (runtimeService(), repositoryService(), taskService(), formService(), etc).
In the example you will see there is a usage of a external script file as well deployment://script1.js
.
You can easily make code changes in the BPMN and .js files, and quickly rerun the tests.
If you connect this up to eclipse or intelliJ you can have the tests auto run as you make updates (but not required).
Note: The test/spec is setup the way it is so you can easily copy and paste to create more complex test/interactive scenarios like running multiple BPMNs that have wait states, external files, templates, etc, and preforms end to end operations (like cleanup at the end (but this is commented out for simplicity)), so you can pretty much just copy and paste from the examples to preform 99% of the typical scripting scenarios.
Also notice how it is mvnw rather than mvn. This is because the maven wrapper is installed in that folder, allowing you to do ./mvnw clean test
as the command. This helps so you do not need to install mvn on the machine running the test/“interactive” output