Linkcheck your Grails application as part of your funcational test

Posted by: on Feb 13, 2007 | No Comments

Canoo WebTest author Dierk König pointed out to me that you can use Webtest which is well integrated with Grails to link check your site locally. This is a must-have functional test to include before deploying.

All you need to do is get webtest setup for your project by running

grails generate-webtest

It will prompt you for a domain class name – put any one of your class names in there, it doesn’t matter. You can delete the generated test afterwards.

After this is done all you need to do is add a test that does the link checking to ./webtest/tests:

class LinkTest extends grails.util.WebTest {    void suite() {        testLinks()        // add tests for more operations here    }

    def testLinks = {        webtest('Link checker') {            invoke(url:'/')            verifyLinks(depth:5, onsiteonly:true)        }    }}

Then you just run the test:

grails run-webtest

…and then check the HTML report in webtest/reports

It would be great if we can get an integrated "release" Grails script that will provide the full workflow for releasing a new site version, including:

  1. Run unit tests
  2. If these pass, run functional tests
  3. If these pass, do full linkcheck
  4. If still going OK, increment version number
  5. Package into a .WAR

It would be very nice. A fair bit of work involved though.

Leave a Reply