Results 1 to 2 of 2

Thread: How to start Grails as a web app when runnning integration tests

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Exclamation How to start Grails as a web app when runnning integration tests

    I'm trying to test my grails app using integration test that makes http requests. Actually it's a selenium/tellurium test, but it doesn't matter. But as i see when i running grails tests it doesn't starts web container, the same time i see many examples in blog articles that people tests grails app using selenium and other test tools that requires http access.

    I've create an empty grails app:

    Code:
    mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.grails -DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.4 -DgroupId=example -DartifactId=testportapp
    
    cd testportapp/
    
    mvn initialize
    
    mvn grails:test-app
    
    Tests PASSED - view reports in target/test-reports
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    thats ok.

    and now add an integration test that tries to connect to grails test/integration/ListenPortTest.groovy:

    Code:
    class ListenPortTest extends GroovyTestCase {
            void testPort(){
                    def s = new Socket("localhost", 8080);
                    s.close()
            }        
    }
    and run test again. Now we receive following exception:

    Code:
    Connection refused
       java.net.ConnectException: Connection refused
       ....
    I've checked it also by using browser, wget and netstat, and looks like grails not started or not opened any port.


    And the question
    : How i can configure grails to open an port when executing integration tests?

    Asked also on stackoverflow: http://stackoverflow.com/questions/3...egration-tests

  2. #2
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Integration tests don't run in a servlet container. You need to install a functional test plugin, like "selenium-rc" and run: grails test-app functional:

    Hope that helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •