|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hi guys, I see on Jira that there are many bugs opened for testing in grails, but I don't understand if there's a way to test the contraints in domain classes or we have to wait for fixes and new grails release. Here a simple exampe: class Scripts { static hasMany = [tags: Tag, parameters: Parameter] String name String fileName static def constraints = { name(blank: false) fileName (blank: false, nullable: false, unique: true) } } And here a very simple test: class ScriptsTests extends GrailsUnitTestCase { protected void setUp() { super.setUp() } protected void tearDown() { super.tearDown() } void testScriptsContraints(){ def existingScript = new Scripts(name: "test1", fileName: "filename1") mockForConstraintsTests(Scripts, [ existingScript ]) def script = new Scripts(); assertFalse script.validate() assertEquals "nullable", script.errors['name'] assertTrue script.errors.filename?.equals('nullable') } If I try to print the value contained in script.errors.name or script.error.fileName I can correctly see an output text saying "nullable". So I think there's some errors inside assertCode or maybe there's something wrong in what I'm doing. Any suggestions to test my domain classes? Thanks a lot Bye Marco - -- Dott. Ing. Mornati Marco Byte-Code s.r.l via Antonio Cechov, 1 San Giuliano Milanese (MI) E-Mail: [hidden email] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkoWgj0ACgkQzqSIKWCQ2AUHIQCfQGuEDQvdB15nZtbcTghVsOGT 8jIAn3MnQtqzHoKLTmOG7I2+cCYhJsH6 =iKvJ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Marco Mornati wrote: > If I try to print the value contained in script.errors.name or > script.error.fileName I can correctly see an output text saying > "nullable". So I think there's some errors inside assertCode or maybe > there's something wrong in what I'm doing. I think you forgot to describe what the problem is, or I'm being dense. Cheers, Marcus -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoWiq0ACgkQXjXn6TzcAQkT/gCg1PbYbqUIJNL4ZYELp+S59lvu wpkAn0vZwISFsiKKx9dwrIx2chtPTDw/ =9CWt -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Yes... maybe your are right... sorry. What I get as error is: expected:<nullable> but was:<null> when I try to check the result with an assertEquals or Could not find which method assertTrue(null) to invoke from this list: public static void junit.framework.Assert#assertTrue(boolean) public static void junit.framework.Assert#assertTrue(java.lang.String, boolean) when I try with an essertTrue. As I said in my previous mail, if I try to print the content of script.errors.name I can see "nullable", so I could expect that assertEquals "nullable", script.errors.name should report "ok" and not "expected:<nullable> but was:<null>". I try with different assert without success. Any idea? Thanks a lot Bye Marco on 05/22/2009 01:21 PM Marcus Better said the following: > Marco Mornati wrote: >> If I try to print the value contained in script.errors.name or >> script.error.fileName I can correctly see an output text saying >> "nullable". So I think there's some errors inside assertCode or maybe >> there's something wrong in what I'm doing. > > I think you forgot to describe what the problem is, or I'm being dense. > > Cheers, > > Marcus > - --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email - -- Dott. Ing. Mornati Marco Byte-Code s.r.l via Antonio Cechov, 1 San Giuliano Milanese (MI) E-Mail: [hidden email] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkoWjGgACgkQzqSIKWCQ2AXqvgCdG8AQAzCi77uReR7oe1x+mUc4 WIQAoINxK4PSBgurvL3hceEUQ894b0tm =TcU2 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
