Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for JUnit Jupiter in the flowable-engine #1227

Merged
merged 6 commits into from Aug 22, 2018

Conversation

filiphr
Copy link
Contributor

@filiphr filiphr commented Aug 15, 2018

Migrate flowable-engine and other dependent modules tests from JUnit 3 / 4 to Junit Jupiter

  • Move used assertions from TestCase into AbstractTestCase (which is no longer extending TestCase) in order not to migrate all tests
  • Add @CleanTest annotation which instructs the internal extensions to clean all deployments of a test
  • Add @EnsureCleanDb annotation which instructs the internal extensions to perform an assertion for a clean DB and drop and create if it wasn't clean
  • Add InternalFlowableExtension - a basis for other internal extensions that offers the following possibilities:
    • Perform a deployment when @Deployment is present before each test method
    • Validate history data after each test
    • Delete history jobs and deployment after each test
    • Assert and ensure clean db after each test (or after all test if TestInstance.Lifecycle#PER_CLASS is used)
    • Support for injecting the ProcessEngine, ProcessEngine services, ProcessEngineConfiguration
      and the id of the deployment done via @Deployment int tests and test lifecycle methods
  • Add LoggingExtension - an extension which performs the test logging for the Flowable tests
  • Add PluggableFlowableExtension - an extension which creates a default ProcessEngine and caches it for all tests
  • Add ResourceFlowableExtension - an extension that starts a new ProcessEngine from a configured resource
    before each test (needs to be used with @RegisterExtensions)
  • Add InternalFlowableSpringExtension - an extension that uses SpringExtension to get the ProcessEngine from the Spring ApplicationContext
  • Adapt TestHelper to user test class, method and the Deployment annotation
  • Add @DeploymentId annotation for injecting the id of a deployment in a test method or test lifecycle methods
  • Do not use @Deployment in ProcessDefinitionEventsService (reason: the listener is required during the deployment)
  • Use @EnabledOnOs for the ShellTaskTest (Should result in 2 ignored tests on each machine)
  • Remove empty test from StandardAgendaFailingTest and disable endless loop test
  • Adapt LDAPTestCase to close the ApacheDSContainer after all tests
  • Modules migrated to use JUnit Jupiter
    • flowable-camel
    • flowable-crystalball (partially)
    • flowable-cxf
    • flowable-dmn-spring-configurator
    • flowable-engine
    • flowable-form-spring-configurator
    • flowable-groovy-script-static-engine
    • flowable-http
    • flowable-ldap-configurator
    • flowable-spring

Modules that have not been migrated will be done in subsequent commits.

I have weird tests failing locally, let's see what Travis says

…3 / 4 to Junit Jupiter

* Move used assertions from TestCase into AbstractTestCase (which is no longer extending TestCase) in order not to migrate all tests
* Add CleanTest annotation which instructs the internal extensions to clean all deployments of a test
* Add EnsureCleanDb annotation which instructs the internal extensions to perform an assertion for a clean DB and drop and create if it wasn't clean
* Add InternalFlowableExtension - a basis for other internal extensions that offers the following possibilities:
  * Perform a deployment when @deployment is present before each test method
  * Validate history data after each test
  * Delete history jobs and deployment after each test
  * Assert and ensure clean db after each test (or after all test if TestInstance.Lifecycle#PER_CLASS is used)
  * Support for injecting the ProcessEngine, ProcessEngine services, ProcessEngineConfiguration
  and the id of the deployment done via @deployment int tests and test lifecycle methods
* Add LoggingExtension - an extension which performs the test logging for the Flowable tests
* Add PluggableFlowableExtension - an extension which creates a default ProcessEngine and caches it for all tests
* Add ResourceFlowableExtension - an extension that starts a new ProcessEngine from a configured resource
before each test (needs to be used with @RegisterExtensions)
* Add InternalFlowableSpringExtension - an extension that uses SpringExtension to get the ProcessEngine from the Spring ApplicationContext
* Adapt TestHelper to user test class, method and the Deployment anotation
* Add DeploymentId annotation for injecting the id of a deployment in a test method or test lifecycle methods
* Do not use @deployment in ProcessDefinitionEventsService (reason: the listener is required during the deployment)
* Use EnabledOnOs for the ShellTaskTest (Should result in 2 ignored tests on each machine)
* Remove empty test from StandardAgendaFailingTest and disable endless loop test
* Adapt LDAPTestCase to close the ApacheDSContainer after all tests
* Modules migrated to use JUnit Jupiter
  * flowable-camel
  * flowable-crystalball (partially)
  * flowable-cxf
  * flowable-dmn-spring-configurator
  * flowable-engine
  * flowable-form-spring-configurator
  * flowable-groovy-script-static-engine
  * flowable-http
  * flowable-ldap-configurator
  * flowable-spring

Modules that have not been migrated will be done in subsequent commits
…flowable-spring modules

* Add FlowableExtension - an extension that creates a default Flowable Engine by using flowable.cfg.xml as a resource
* Add FlowableSpringExtension - an extension that uses SpringExtension to get the process engine and pass it to the FlowableExtension
* Add FlowableTestHelper - a container for the Flowable extension that has the ProcessEngine and helper methods that can be used within tests
* Add FlowableTest - an annotation that can be used instead of @ExtendWith(FlowableExtension.class)
* Enhance TestHelper to be able to register mocks directly from the MockServiceTask and NoOpServiceTasks annotations
* Add support for using the MockServiceTask#id
@lamtrhieu
Copy link
Contributor

Hi @filiphr
I am really interested in viewing this PR but the file changes is really too much for me. Why don't you break it down into smaller ones instead ?

@filiphr
Copy link
Contributor Author

filiphr commented Aug 20, 2018

Hey @lamtrhieu thanks for your interested in the PR. The PR is actually already done in the smallest possible pieces (See the multiple commits). However, due to the scope of the PR (migrating the entire testing framework and test of the flowable-engine) there are more than 2000 tests that are affected by this change. Have a look at all files which are not ending on Test.java for the actual more meaningful changes

…owable5-test module

The flowable5 tests should continue running on the old JUnit 3 infrastructure
@tijsrademakers tijsrademakers merged commit d05e91f into flowable:master Aug 22, 2018
@filiphr filiphr deleted the jupiter branch August 22, 2018 11:46
@dbmalkovsky
Copy link
Contributor

dbmalkovsky commented Aug 22, 2018

@filiphr This change looks wrong in
modules/flowable-camel/src/test/java/org/flowable/camel/AsyncPingTest.java

 -   @Override
 +   @Test
     public void tearDown() throws Exception {
         List<Route> routes = camelContext.getRoutes();
         for (Route r : routes) {

I think it should be @AfterEach instead of @Test

@filiphr
Copy link
Contributor Author

filiphr commented Aug 22, 2018

You are completely right @dbmalkovsky. Thanks a lot for letting us know. I have just fixed that in b65bfb5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants