I have created a new Grails 3.1.4 angular project along with a few domain objects and controllers extending RestfulController
. I have created the Integration test below. When I run grails test-app -integration
I get the error
java.lang.IllegalStateException: No transactionManager was specified. Using @Transactional or @Rollback requires a valid configured transaction manager. If you are running in a unit test ensure the test has been properly configured and that you run the test suite not an individual test method.
at grails.transaction.GrailsTransactionTemplate.<init>(GrailsTransactionTemplate.groovy:60)
at com.waldoware.invoicer.BillingEntityRestControllerIntegrationSpec.$tt__$spock_feature_0_0(BillingEntityRestControllerIntegrationSpec.groovy:29)
at com.waldoware.invoicer.BillingEntityRestControllerIntegrationSpec.test all entities_closure2(BillingEntityRestControllerIntegrationSpec.groovy)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:442)
at grails.transaction.GrailsTransactionTemplate$1.doInTransaction(GrailsTransactionTemplate.groovy:70)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at grails.transaction.GrailsTransactionTemplate.executeAndRollback(GrailsTransactionTemplate.groovy:67)
at com.waldoware.invoicer.BillingEntityRestControllerIntegrationSpec.test all entities(BillingEntityRestControllerIntegrationSpec.groovy)
Test class:
package com.waldoware.invoicer
import grails.test.mixin.integration.Integration
import grails.transaction.*
import spock.lang.*
@Integration
@Rollback
class BillingEntityRestControllerIntegrationSpec extends Specification {
def setupData() {
def biller = new BillingEntity()
biller.with {
companyName = "Acme, Inc."
}
def ledger = new Ledger(name: "My Ledger", billingEntity: biller).save(failOnError: true, flush: true)
}
void 'test all entities'() {
when:
setupData()
new BillingEntityRestController().index()
then:
response.contentType == 'application/json;charset=UTF-8'
response.status == HttpServletResponse.SC_OK
response.text == "[{}]"
}
}
Aucun commentaire:
Enregistrer un commentaire