Grails-Gradle-Plugin getting Integration Tests to run (or confirm that they have indeed run)

Hey All,

Thanks in advance for any help :smiley: . And apologize if this is the wrong topic was unsure if this is actual a problem or a question:P

I am attempting to use the grails-gradle-plugin for a college project. My hope was to impress the “aul” college lecturers with Gradle & Grails and all their Groovyness. I have run into some problems getting the simplest of examples running, I will try to be as clear as I can and please feel free to correct me. My issue at the moment is in testing with a difference in output between “gradle grails-test-app” and “gradle iT” [camel casing for a task I defined integrationTest] the former produces an error message of (extracted from a reports file in build/test-reports/ folder)

groovy.lang.MissingMethodException: No signature of method: database.Person.save() is applicable for argument types: ()

and the latter appears to succeed (or at least produce no output) I would like to understand why this is happening, will it be a problem when building the project in the end and whether or not the integration test is succeeding or not? What follows is the key items from the project.

My Environment is Gradle 1.6,

Groovy 1.8.6,

Linux 3.8.0-25-generic amd64,

JVM 1.7 running on an Alienware m17x My directory structure is the default created by the plugin when you type “gradle init” on the command line. The following is the build.gradle for the project:

buildscript {
      repositories {
        maven { url "http://repo.grails.org/grails/repo"}
    }
      dependencies {
        classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT"
    }
}
  repositories {
    maven { url "http://repo.grails.org/grails/repo"}
}
apply plugin: "grails"
apply plugin: "java"
apply plugin: "idea"
version
"0.1"
group "localshop"
  grails{
    grailsVersion "2.2.2"
}
  dependencies {
    compile "org.grails:grails-plugin-tomcat:$grails.grailsVersion"
    compile "org.apache.commons:commons-lang3:3.1"
}
  test {
    testLogging {
        events "started", "passed"
    }
}
  import org.grails.gradle.plugin.GrailsTask
  task unitTest(type: GrailsTask) {
    command "test-app"
    args "unit"
}
  task integTest(type: GrailsTask) {
    command "test-app"
    args "integration"
}

I created a domain class ( + the unit test) and an integration test from the command line. The domain class Person has the following “attributes” and has no constraints as of yet:

private String fullName
private String email
private String salt
private String password
private int age

My UnitTest for Person simply calls assertEquals 1, 1 and this is my minimum working example. The Integration Test itself is as follows:

package database
  import static org.junit.Assert.*
import org.junit.*
import org.apache.commons.lang3.RandomStringUtils
  class AddressIntegrationTests {
      def testUser
          @Before
    void setUp() {
        testUser = new Person(fullName: createRandomString(createRandomNumber()),
                              email: createRandomString(createRandomNumber()),
                              password: createRandomString(createRandomNumber()),
                              salt: createRandomString(createRandomNumber()),
                              age: createRandomNumber()
                             )
    }
      @After
    void tearDown() {
        testUser = null
    }
      @Test
    void testSomething() {
        testUser.save(flush: true)
        def userId = Person.get(testUser.id)
        assertEquals "The number of errors when saving the testUser is greater than zero", testUser.errors.count , 0
        assertEquals "The userId is null", userId , null
        assertEquals "The saved testUserId does not match the one in the object", Person.get(userId).userId, userId
        asserTrue 1 == 2
    }
      private String createRandomString(int size) {
        return RandomStringUtils.random(size)
    }
      private int createRandomNumber() {
        return RandomStringUtils.randomNumeric(2).toInteger()
    }
}

To summarize the issue I am having is that when I run this integration test with gradle grails-test-app and my own self defined task gradle integTest they produce and error in the formers case and no output on the other and as such I am not sure if the integration tests are succeding or failing and can’t advance the project. I have the following theories myself: -The tests fail in the first case because of the so called pollution that the unit tests cause and succeed in the second case because of the lack of unit tests being run - in which case why is their no discernible output to inform me of this ; Or -I have done everything wrong and missing something glaringly obvious about this whole thing :smiley:

Thanks again for any help and sorry in advance if its a stupid question, I may have further questions also :wink: -E

I don’t know why you aren’t getting any output, but the root cause is probably that you aren’t pulling in the domain class or hibernate plugins.