Robot’s design seems to assume that everything must be a single line (unless preceded by "… "). FitNesse only read the testcase file until it read a “keyword”, and then allowed the keyword code (what they called a fixture) to consume as much of the testcase as it wanted. Which allowed you to create fixtures that could gobble up multiline data.
It seems that Robot parses the whole file first, into a token tree, and then executes from the tree.
I looked into the get_tokens() method, but it didn’t seem to report the error tokens. I was hoping I could “fix up” the model before executing it, but alas, I don’t think I can.
Ultimately, I would love to be able to create a testcase like below.
Does anyone know if/how I could hack into the token tree creation logic to allow a callback to the keyword class so that it could direct the parser how to handle the testcase data?
My thoughts are that if the parser doesn’t understand what the line is, instead of assuming an error, it could find the previous keyword and attempt a callback (would it know what library/class it came from?) to see if it should classify the line as “data”. But then I am not certain if that is the right direction to go.
*** Test Cases ***
TEST_POST
Post Request ${url}/resturi
Set Headers
Content-Type=application/json
Auth=Basic Y24zNTIzOjY2JCFCYWlsZXlMaW51cw
Set Body
{
“clusterInfo”: {
“tfwNumber”: “TX-9709-00”,
“clusterId”: 1,
“projectStatus”: “Initial”,
“tfwSpreadsheetURL”: “url”,
“tfwRequestURL”: “url”
},
“nodes”: [
{
“nodeNum”: 1,
“nodeId”: 119,
“totalCost”: 999,
“fiberConstDays”: 99,
“estimatedLoopLoss”: 9999,
“directNewReusable”: 99.99,
“directNewNonReusable”: 99.99,
“associatedNewReusable”: 99.99,
“associatedNewNonReusable”: 99.99
},
{
“clusterNodeId”: 1,
“nodeNum”: 2,
“nodeId”: 22,
“dropCost”: 888,
“totalCost”: 888,
“directNewReusable”: 99.99,
“directNewNonReusable”: 99.99,
“associatedNewReusable”: 99.99,
“associatedNewNonReusable”: 99.99
}
]
}
Expect
nodes.nodeId == 119
Done
Yes, I know you can use the continuation token, but then the developer has to prepend "… " in front of every line of data.
I want to create keywords that can parse the testcase itself, and pull the data directly from the file… and not have to assign it to a variable. Also, I know you can import data from a file, but that goes against our testcase design philosophy, a testcase must be “standalone”… and no rely on any outside data or configuration.
I know, I know… I am trying to stretch Robot in ways that it was never designed to go… but if it could, you could really increase the flexibility and power of the tool, without causing the developer to write huge amounts of Robot code.