|
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 |
|
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")]
|
|
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, Thanks and regards, Ravi Teja |
|
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:
-- regards, Jawad Bokhari |
| Powered by Nabble | Edit this page |
