Search code examples
javarestgroovyautomated-testswebtau

How do I specify base url for REST API tests with WebTau


In WebTau documentation on how to test CRUD, examples are using relative urls

def customerPayload = [firstName: "FN", lastName: "LN"]

def id = http.post("/customers", customerPayload) {
    return id
}

http.get("/customers/${id}") {
    body.should == customerPayload
}

How do I set base url to use?


Solution

  • If you are using Groovy standalone runner you can base url via command line

    webtau --url=http://localhost:8080
    

    or have a groovy config file webtau.cfg.groovy

    url = "http://localhost:8080
    

    In case of Java src/test/resources/webtau.properties file

    url = http://localhost:8080
    

    or pass it via system property for test execution

    -Durl="http://localhost:8080"
    

    for both Java and Groovy you can also provide base url via environment variable

    WEBTAU_URL=http://localhost:8080