Grails IntegrationSpec非法状态异常

Grails IntegrationSpec非法状态异常,grails,integration-testing,spock,grails-2.4,Grails,Integration Testing,Spock,Grails 2.4,在从2.4.0升级到2.4.2之后,我在运行集成测试时遇到了一个错误。它表明测试通过了,但是我得到了一个非法状态异常 Failure: | massemailsystem.UserInformationIntegrationSpec | java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first at grails.util.Holde

在从2.4.0升级到2.4.2之后,我在运行集成测试时遇到了一个错误。它表明测试通过了,但是我得到了一个非法状态异常

    Failure:  |
massemailsystem.UserInformationIntegrationSpec
 |
java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
    at grails.util.Holders.getApplicationContext(Holders.java:97)
    at grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41)
我试着分析测试结果,没有发现任何异常。这是完整的测试。我正在测试从LDAP数据源获取信息

abstract class DirectoryIntegrationSpec extends IntegrationSpec {

    DirContextOperations getContext(Map attrs) {
        DirContextAdapter d = new DirContextAdapter()
        attrs.each { k, v ->
            if (v != null) {
                d.addAttributeValue(k, v)
            }
        }
        d
    }
}


class UserInformationIntegrationSpec extends DirectoryIntegrationSpec {

    def dataSource

    def setup() {
        new SPRIDEN(pidm: 100, yNumber: 'Y00100', lastName: 'Smith').save(flush: true, failOnError: true)
        new SPBPERS(pidm: 100, prefFirstName: 'Joe', activityDate: new Date(), armedServMedVetInd: 'N').save(flush: true, failOnError: true)
        new SPRTELE(pidm: 100, seqNo: 1, teleCode: 'CE', activityDate: new Date(), primaryInd: 'Y', phoneArea: '330', phoneNumber: '1234567').save(flush: true, failOnError: true)

        new SPRIDEN(pidm: 102, yNumber: 'Y00102', lastName: 'Smith').save(flush: true, failOnError: true)
        new SPRTELE(pidm: 102, seqNo: 1, teleCode: 'CE', activityDate: new Date(), primaryInd: 'Y', phoneArea: '330', phoneNumber: '1234567').save(flush: true, failOnError: true)

        new SPRIDEN(pidm: 103, yNumber: 'Y00103', lastName: 'Smith').save(flush: true, failOnError: true)
    }

    def cleanup() {
    }

    @Unroll
    void "test constructor from LDAP for fake #employeeid"() {
        when:
        def context = getContext([employeeid: employeeid, givenname: firstName, sn: lastName, mail: email])
        UserInformation u = new UserInformation(context, username, dataSource)

        then:
        u.id == id
        u.firstName == prefFirstName
        u.lastName == lastName
        u.email == email
        u.phone == phone
        u.department == department
        u.username == username

        where:
        employeeid | username | id   | firstName | prefFirstName | lastName | email            | phone            | department
        'Y00100'   | 'jsmith' | 100  | 'Joseph'  | 'Joe'         | 'Smith'  | 'jsmith@ysu.edu' | '(330) 123-4567' | null
        "Y00101"   | null     | null | null      | null          | null     | null             | null             | null
        "Y00102"   | 'jsmith' | 102  | 'Joseph'  | 'Joseph'      | 'Smith'  | 'jsmith@ysu.edu' | '(330) 123-4567' | null
        "Y00103"   | 'jsmith' | 103  | 'Joseph'  | 'Joseph'      | 'Smith'  | null             | null             | null
    }
}
提前谢谢


编辑:当我自己运行测试时,它不会失败,只有当我运行所有的集成测试时才会失败。

我这边有个愚蠢的问题

测试之前的测试使用@TestFor注释和扩展规范,而它本应该扩展IntegrationSpec,而根本没有注释。我将此规范从一个单元更改为一个集成,但我未能更改这些内容


有趣的是,测试本身运行得很好,只有在测试之后运行的测试出现了问题。

我这边有个愚蠢的问题

测试之前的测试使用@TestFor注释和扩展规范,而它本应该扩展IntegrationSpec,而根本没有注释。我将此规范从一个单元更改为一个集成,但我未能更改这些内容

有趣的是,测试本身运行良好,只有在测试之后运行的测试出现问题