How to run Grails integration tests against a running server?
I've searched the web but the advices date to 2010 and Grail 1.3.x...
How to run Grails integration tests against a running server?
I've searched the web but the advices date to 2010 and Grail 1.3.x...
Grails 3 Integration test will run against a running server. You need to define a test environment application.yml and add the @Integration annotation to your class.
import grails.test.mixin.integration.Integration
import spock.lang.Specification
@Integration
class LookupServiceIntegrationSpec extends Specification {
def lookupService
def setup() {
}
def cleanup() {
}
void "test database connection"() {
when:
def row = lookupService.testMethod()
then:
println("Row one = "+row.one)
row.one == 1
}
}
Here is a simple example service:
import grails.transaction.Transactional
import groovy.sql.Sql
@Transactional
class LookupService {
def dataSource
def testMethod() {
Sql sql = new Sql(dataSource)
sql.firstRow("SELECT 1 AS one")
}
}
Maybe your looking for Functional Tests not Integration Tests. Grails 3 added better support for Functional Tests. See Link Below.