1
從2.4.0升級到2.4.2後,我在運行集成測試時出現錯誤。它顯示測試通過,但是我得到一個IllegalStateException。Grails IntegrationSpec IllegalStateException
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' | '[email protected]' | '(330) 123-4567' | null
"Y00101" | null | null | null | null | null | null | null | null
"Y00102" | 'jsmith' | 102 | 'Joseph' | 'Joseph' | 'Smith' | '[email protected]' | '(330) 123-4567' | null
"Y00103" | 'jsmith' | 103 | 'Joseph' | 'Joseph' | 'Smith' | null | null | null
}
}
在此先感謝!
編輯:測試不會失敗,當我運行它自己,只有當我運行我所有的集成測試。