Forum Discussion

skjoldan's avatar
skjoldan
Occasional Contributor
14 years ago

using property from command line in assertion

hi,

I have some scripts, that we are calling from the command line via testrunner.

As we are running against different hosts, I would like to be able to do some assertions against the different host, depending on what host property we have put into the command like.

Like we are running:
testrunner.bat -h 'hostAndPort' Test.

Then I would like to pull out the host and port from this request into my test, is that possible?

Regards
Skjoldan

2 Replies

  • I am unaware of a method to directly access the value of that parameter.

    Here is an indirect method. Use this to get the Endpoint of a specific Test Step:

    def endpoint = context.expand( '${TestStepName#Endpoint}' )
    log.info "${endpoint}";


    This will give you the entire URL. Then you could use groovy to parse out the 'hostAndPort' part (everything between 'http://' and the next '/')

    I know it's not exactly what you wanted, but close.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    one alternative is to put the host in a project-level property that you use via property expansion in both your endpoints and assertions (ie with ${#Project#Host}). When running from the command-line you can override its value with -Phost=....

    maybe that works?!

    regards,

    /Ole
    eviware.com