Quantcast

running geb tests as plain unit tests

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

running geb tests as plain unit tests

houbie
Hi,

Geb tests are normally started using the functional test phase. This means that during development of the tests, you spend most of the time waiting for the application to start :(
By executing:
            RuntimeAdapter.baseUrl = 'http://localhost:8080/myapp/'
            RuntimeAdapter.reportDir = new File('testreportsdir/geb')
before starting the geb test (f.e. in setup), you can start the test from within the IDE (assuming your application is already running).

While trying this out, I noticed that geb looses the http session in between tests when running with test-app while it remembers the session when started as described above.

So my question is: is there a way to control the session behavior of geb tests?

Regards,
Ivo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: running geb tests as plain unit tests

Predrag Knezevic
  Hi,

  perhaps you could use this plugin:

https://github.com/alkemist/grails-functional-test-development

  Greetings,

Predrag

On Fri, Jan 14, 2011 at 3:29 PM, houbie <[hidden email]> wrote:

>
> Hi,
>
> Geb tests are normally started using the functional test phase. This means
> that during development of the tests, you spend most of the time waiting for
> the application to start :(
> By executing:
>            RuntimeAdapter.baseUrl = 'http://localhost:8080/myapp/'
>            RuntimeAdapter.reportDir = new File('testreportsdir/geb')
> before starting the geb test (f.e. in setup), you can start the test from
> within the IDE (assuming your application is already running).
>
> While trying this out, I noticed that geb looses the http session in between
> tests when running with test-app while it remembers the session when started
> as described above.
>
> So my question is: is there a way to control the session behavior of geb
> tests?
>
> Regards,
> Ivo
> --
> View this message in context: http://grails.1312388.n4.nabble.com/running-geb-tests-as-plain-unit-tests-tp3217745p3217745.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
>
>
>

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

    http://xircles.codehaus.org/manage_email


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

Re: running geb tests as plain unit tests

ld@ldaley.com
In reply to this post by houbie

On 15/01/2011, at 12:29 AM, houbie wrote:

> Geb tests are normally started using the functional test phase. This means
> that during development of the tests, you spend most of the time waiting for
> the application to start :(
> By executing:
>            RuntimeAdapter.baseUrl = 'http://localhost:8080/myapp/'
>            RuntimeAdapter.reportDir = new File('testreportsdir/geb')
> before starting the geb test (f.e. in setup), you can start the test from
> within the IDE (assuming your application is already running).
>
> While trying this out, I noticed that geb looses the http session in between
> tests when running with test-app while it remembers the session when started
> as described above.
>
> So my question is: is there a way to control the session behavior of geb
> tests?

What superclass are you using for your tests?

The provided superclasses for JUnit3, JUnit4 and Spock all call the geb.Browser#clearCookiesQuietly() method.

https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/Browser.groovy#L174

If you don't want to use one of these classes then you can just call this method after each test.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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

Re: running geb tests as plain unit tests

houbie

>
> What superclass are you using for your tests?
>
grails.plugin.geb.GebTests

> The provided superclasses for JUnit3, JUnit4 and Spock all call the geb.Browser#clearCookiesQuietly() method.
>
> https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/Browser.groovy#L174
>
> If you don't want to use one of these classes then you can just call this method after each test.

So I will just call "RuntimeAdapter.baseUrl = 'http://localhost:8080/myapp/'" in setUp
and call "browser.clearCookiesQuietly()" in tearDown().
This way it will behave the same wether running from grails commandline or from IDEA :)

Thanks for pointing out.
Ivo
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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

Re: running geb tests as plain unit tests

ld@ldaley.com

On 18/01/2011, at 7:12 AM, Ivo Houbrechts wrote:

>>
>>
>> What superclass are you using for your tests?
>>
> grails.plugin.geb.GebTests
>
>> The provided superclasses for JUnit3, JUnit4 and Spock all call the geb.Browser#clearCookiesQuietly() method.
>>
>> https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/Browser.groovy#L174
>>
>> If you don't want to use one of these classes then you can just call this method after each test.
>
> So I will just call "RuntimeAdapter.baseUrl = 'http://localhost:8080/myapp/'" in setUp
> and call "browser.clearCookiesQuietly()" in tearDown().
> This way it will behave the same wether running from grails commandline or from IDEA :)

This should work out of the box, but obviously doesn't:

https://github.com/geb/geb/blob/master/module/geb-junit4/src/main/groovy/geb/junit4/GebTest.groovy#L63

It may be the case that JUnit4 won't call @After methods if it suspects the test case is JUnit3 based, which could be the case here because we use GroovyTestCase.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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

Re: running geb tests as plain unit tests

houbie
In reply to this post by houbie
After upgrading to geb 0.6.0, running geb tests from within the IDE has become easier. You only have to override the createConf method of GebReportingTest:

class MyGebTest extends GebReportingTest {

    Configuration createConf() {
        ConfigurationLoader loader = new ConfigurationLoader(gebConfEnv)
        Configuration config = loader.getConf(gebConfScript)
        if (!config.reportsDir) {
            config = loader.getConf(new File('./test/functional/GebConfig.groovy').toURL(), new GroovyClassLoader())
        }
        return config
    }
...

This makes sure that GebConfig.groovy will be loaded, even if the test wasn't started by Grails.

Grtz,
Ivo

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

Re: running geb tests as plain unit tests

ld@ldaley.com

On 14/07/2011, at 5:27 PM, houbie wrote:

> After upgrading to geb 0.6.0, running geb tests from within the IDE has
> become easier. You only have to override the createConf method of
> GebReportingTest:
>
> class MyGebTest extends GebReportingTest {
>
>    Configuration createConf() {
>        ConfigurationLoader loader = new ConfigurationLoader(gebConfEnv)
>        Configuration config = loader.getConf(gebConfScript)
>        if (!config.reportsDir) {
>            config = loader.getConf(new
> File('./test/functional/GebConfig.groovy').toURL(), new GroovyClassLoader())
>        }
>        return config
>    }
> ...
>
> This makes sure that GebConfig.groovy will be loaded, even if the test
> wasn't started by Grails.

Another option is to make test/functional a classpath entry in your IDE.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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

Re: running geb tests as plain unit tests

J. David Beutel-4

> Another option is to make test/functional a classpath entry in your IDE.

Or, I add GebConfig.groovy to IntelliJ's Compiler -> Resource patterns.

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

    http://xircles.codehaus.org/manage_email


Loading...