All Downloads are FREE. Search and download functionalities are using the official Maven repository.

FitNesseRoot.RestFixtureTests.LetTests.content.txt Maven / Gradle / Ivy

Usages of LET (See also PostTests for more examples) 

''LET used to extract values from header, using regular expressions''

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|setBody|BillSome data on Bill|
|POST   | /resources/ | 201 | | no-body |
|let    | id | header | Location:/resources/(.+) | |

The regex is applied to each header. On the first match the first group is extracted and
assigned as value to the label ''id''.

Labels are global and can be shared across rest fixture instances.

''LET used to extract values from XML body via XPath''
''Values are re-usable across instances of .RestFixture''

Here follows an usage of the previously extracted ''id''.
This example also shows how to use let to extract data from the XML body of a response using XPath.

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/%id% | 200 | |!-
 /resource/name[text()='Bill']
/resource/data[text()='Some data on Bill'] -! | |let | name | body | /resource/name/text() | | ...or from a JSON body | Table: Rest Fixture |http://${jettyHost}:${jettyPort}| |GET | /resources/1.json | 200 |Content-Type : application/json|!- jsonbody.resource.name=='a funky name'
jsonbody.resource.data=='an important message' -! | |let | name | body | /resource/name/text() | | !*** Note Label values can be accessed from code using '''new Variables().get("labelname");''' ***! ''LET resolves names from Fixture Symbol map if not found in the local map'' !-LetTestSupport -! allows to get/set values in the Fixture Symbol map | script |!-smartrics.rest.test.fitnesse.fixture.LetTestSupport-!| |assign|/resources| |$resType=|value| !*** Note Look at the source code of this page to see that the resource URI for the GET method below is defined as '''%resType%/%id%''' ***! | Table: Rest Fixture |http://${jettyHost}:${jettyPort}| |GET | %resType%/%id% | 200 | | | |let | theName | body | /resource/name/text() | | | script |!-smartrics.rest.test.fitnesse.fixture.LetTestSupport-!| |assign| $theName | | check |value |Bill| Other fixtures can set a value in the symbol map with ''Fixture.setSymbol''. The .RestFixture can then pick them up This fixture sets ''symbolName=/resources''... | script |!-smartrics.rest.test.fitnesse.fixture.LetTestSupport-!| |assign|/resources| |$aNameOfASymbol=| value| ... then the value is used by the .RestFixture | Table: Rest Fixture |http://${jettyHost}:${jettyPort}| |GET | %aNameOfASymbol%/%id% | 200 | | |




© 2015 - 2024 Weber Informatics LLC | Privacy Policy