Quantcast

Integration tests :

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

Integration tests :

Piettes
Hi,

I'm trying to make some integration tests, but it seems I can't modify data in my database.
I populate my database (mysql) in the bootstrap.groovy.

Here is my simple test :

class ExponentIntegrationTests extends GroovyTestCase {
        protected void setUp() {
                super.setUp()
        }
        protected void tearDown() {
                super.tearDown()
        }

        void testSuppressExponent() {
                println(Exponent.count())
                Exponent.get(2).delete()
                println(Exponent.count())
        }
}

The test passe, but it write  "3 - 3" -> the object Exponent hasn't been deleted.

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

Re: Integration tests :

Jose Juan Reyes
One thing...
All the test are executed in the the test environment, this mean, the configuration that you have in the datasource is used, so if you have a DB in development this is ignored...
Maybe you must specify the env...
Regards

2011/3/2 Piettes <[hidden email]>
Hi,

I'm trying to make some integration tests, but it seems I can't modify data
in my database.
I populate my database (mysql) in the bootstrap.groovy.

Here is my simple test :

class ExponentIntegrationTests extends GroovyTestCase {
       protected void setUp() {
               super.setUp()
       }
       protected void tearDown() {
               super.tearDown()
       }

       void testSuppressExponent() {
               println(Exponent.count())
               Exponent.get(2).delete()
               println(Exponent.count())
       }
}

The test passe, but it write  "3 - 3" -> the object Exponent hasn't been
deleted.

Any ideas ?

--
View this message in context: http://grails.1312388.n4.nabble.com/Integration-tests-tp3331919p3331919.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





--
(¯`·._.·[Jµðn]·._.·´¯)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Integration tests :

Shin Tai
In reply to this post by Piettes
On 2 March 2011 17:28, Piettes <[hidden email]> wrote:

> Hi,
>
> I'm trying to make some integration tests, but it seems I can't modify data
> in my database.
> I populate my database (mysql) in the bootstrap.groovy.
>
> Here is my simple test :
>
> class ExponentIntegrationTests extends GroovyTestCase {
>        protected void setUp() {
>                super.setUp()
>        }
>        protected void tearDown() {
>                super.tearDown()
>        }
>
>        void testSuppressExponent() {
>                println(Exponent.count())
>                Exponent.get(2).delete()
>                println(Exponent.count())
>        }
> }
>
> The test passe, but it write  "3 - 3" -> the object Exponent hasn't been
> deleted.
>
> Any ideas ?
>

Try a flush when you delete:

Exponent.get(2).delete(flush: true)

If that works then read:
http://blog.springsource.com/2010/06/23/gorm-gotchas-part-1/

Shin

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

    http://xircles.codehaus.org/manage_email


Loading...