Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15755

Spring Boot tests broken when using TestInstance.Lifecycle.PER_CLASS

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Abandoned
    • 3.6.0
    • 3.x
    • camel-spring, camel-test
    • None
    • Unknown

    Description

      After upgrading to 3.6.0 existing Spring Boot tests in my codebase started to fail. After some investigation I discovered that this is due to my unit tests having a single instance per class as configured using JUnit's 

      @TestInstance(TestInstance.Lifecycle.PER_CLASS)

      Some changes were introduced in a recent commit that affected the existing behaviour in CamelSpringBootExecutionListener: https://github.com/apache/camel/commit/efc34ab2b98f3697ebb482cf1645fda6f0794797

      I have remediated my tests by running the following code in a JUnit BeforeEach method within a base test class:

      // Kotlin
      @BeforeEach
      fun init() {
          SpringCamelContext.setNoStart(false)
          camelContext.start()
      }
      

      I am currently looking for a more permanent solution to this issue that properly supports single instance JUnit5 Test classes.

      Attachments

        Activity

          People

            Unassigned Unassigned
            alex.arana Alex Arana
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: