Quantcast

Grails Domain Class Integration Test

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails Domain Class Integration Test

jawad.bokhari
I am using Grails 2.0.4,
New to grails and testing the very first Integration test, which is failing despite several hit-n-tries :(

I have created a very simple domain class, User.groovy:


package com.grailsinaction

class User {
    String userId
    String password
    String homepage
    Date dateCreated
    
    static constraints = {
    }
}

And created an integration test for the same with the name UserIntegrationTests.groovy:


package com.grailsinaction

import static org.junit.Assert.*
import org.junit.*

class UserIntegrationTests {

    @Before
    void setUp() {
        // Setup logic here
    }

    @After
    void tearDown() {
        // Tear down logic here
    }

    @Test
    void testFirstSaveEver() {
        def users = [
            new User(userID:'jawad', password:'mango', homepage:'http://www.mango.com'),
            new User(userID:'mango', password:'tango', homepage:'http://www.mango.com')]
            
        users*.save(flush: true)
        
        assertEquals 2, User.list().size()
    }
}

This always fails and says:
expected:<2> but was:<0>


Thanks for any hints
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Domain Class Integration Test

jawad.bokhari
Got this stupid issue resolved,
I had to use double quotes instead of single quotes while saving the string values in my domain class object.
I need to check when to use single quotes and when to double them.

def users = [
            new User(userID:'jawad', password:'mango', homepage:'http://www.mango.com'),
            new User(userID:'mango', password:'tango', homepage:'http://www.mango.com')]
It should have been like following:

def users = [
            new User(userID:"jawad", password:"mango", homepage:"http://www.mango.com"),
            new User(userID:"mango", password:"tango", homepage:"http://www.mango.com")]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Domain Class Integration Test

bond_
I think this will help: http://groovy.codehaus.org/Strings+and+GString

On Wed, Jul 4, 2012 at 11:06 PM, jawad.bokhari <[hidden email]> wrote:
Got this stupid issue resolved,
I had to use double quotes instead of single quotes while saving the string
values in my domain class object.
I need to check when to use single quotes and when to double them.


It should have been like following:



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Domain-Class-Integration-Test-tp4631077p4631079.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Thanks and regards,
Ravi Teja

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails Domain Class Integration Test

jawad.bokhari
Thanks, it was pretty confusing. The link was quite helpful.

Jawad

On Thu, Jul 5, 2012 at 5:20 PM, Raviteja Lokineni <[hidden email]> wrote:
On Wed, Jul 4, 2012 at 11:06 PM, jawad.bokhari <[hidden email]> wrote:
Got this stupid issue resolved,
I had to use double quotes instead of single quotes while saving the string
values in my domain class object.
I need to check when to use single quotes and when to double them.


It should have been like following:



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Domain-Class-Integration-Test-tp4631077p4631079.html

Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Thanks and regards,
Ravi Teja




--
regards,
Jawad Bokhari

Loading...