How to start Grails as a web application when performing integration tests

I am trying to test a grails application with an integration test that makes HTTP requests. This is actually a selenium / tellurium test, but it does not matter. But, as I see it, when I run the Grails tests, it does not launch the web container, at the same time I see many examples in the blog articles that people test the grails application using selenium and other testing tools that require http access.

I am creating an empty grails application:

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:

class ListenPortTest extends GroovyTestCase {
        void testPort(){
                def s = new Socket("localhost", 8080);
                s.close()
        }        
}

and repeat the test. Now we get the following exception:

Connection refused
   java.net.ConnectException: Connection refused
   ....

, , wget netstat, , grails - .

: grails ?

+3

Source: https://habr.com/ru/post/1764803/


All Articles