Grails

ConfigurationHelper.config null in integration tests (was GRAILS-4780)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 1.2 final
  • Fix Version/s: 1.2.1
  • Component/s: Testing
  • Labels:
    None
  • Testcase included:
    yes

Description

ConfigurationHolder.config seems to be set for the first integration test run and is null from then on (unless mocked using mockConfig). I would expect it to be null for unit tests, but not integration tests. Running the following as an integration test results in testConfigHolder1 passing and testConfigHolder2 failing.

ConfigHolderTests.groovy
import grails.test.*
import org.codehaus.groovy.grails.commons.ConfigurationHolder

class ConfigHolderTests extends GrailsUnitTestCase {
  void testConfigHolder1() {
    assert ConfigurationHolder.config
  }
  
  void testConfigHolder2() {
    assert ConfigurationHolder.config
  }
}

Issue Links

Activity

Hide
Dave Bower added a comment -

Apologies for being a jira noob as having cloned this issue I find I can't modify it. However, I just ran the attachment in 1.2.0 and it failed so I assume it's regressed or was not fixed in 1.2? Since I couldn't find it anywhere else in jira I created a new issue.

If someone with perms could adjust the Affects Version/s to 1.2 and remove "Fix Version/s" I'd be obliged.

Show
Dave Bower added a comment - Apologies for being a jira noob as having cloned this issue I find I can't modify it. However, I just ran the attachment in 1.2.0 and it failed so I assume it's regressed or was not fixed in 1.2? Since I couldn't find it anywhere else in jira I created a new issue. If someone with perms could adjust the Affects Version/s to 1.2 and remove "Fix Version/s" I'd be obliged.
Hide
Jeff Brown added a comment -

The tearDown method in GrailsUnitTestCase is setting ConfigurationHolder.config to null. I am not sure what the right thing to do is here. Remove that? Set it to null in setUp so it is always null and force tests to use mockConfig if they want a config?

Show
Jeff Brown added a comment - The tearDown method in GrailsUnitTestCase is setting ConfigurationHolder.config to null. I am not sure what the right thing to do is here. Remove that? Set it to null in setUp so it is always null and force tests to use mockConfig if they want a config?
Hide
Gabe Beged-Dov added a comment -

Would it be possible to deal with this at a higher level like in _GrailsTest.integrationTestPhasePreparation to avoid backwards compatibility issues?

Show
Gabe Beged-Dov added a comment - Would it be possible to deal with this at a higher level like in _GrailsTest.integrationTestPhasePreparation to avoid backwards compatibility issues?

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: