Here is a sample scenario that shows the syntax highlighting is not working correctly, however the code is not affected by this, just the visual aspect. (test is just to show highlighting, not an actual test in use)
Feature:
Scenario Outline:
* def x = 1
* def output = x != null ? (100 + <add>) : null
* print 'output for add is ', output
* def output = x != null ? (100 - <subtract>) : null
* print 'output for subtract is ', output
* def output = x != null ? (100 * <times>) : null
* print 'output for times is ', output
* def output = x != null ? (100 / <divide>) : null
* print 'output for divide is ', output
* def output = <add> != null ? (100 + <add>) : null
* print 'output for add is ', output
* def output = <subtract> != null ? (100 - <subtract>) : null
* print 'output for subtract is ', output
* def output = <times> != null ? (100 * <times>) : null
* print 'output for times is ', output
* def output = <divide> != null ? (100 / <divide>) : null
* print 'output for divide is ', output
Examples:
| add | subtract | times | divide |
| 1 | 2 | 3 | null |
| 2 | 3 | null | 4 |
Here is what the syntax highlighting looks like in vsCode.
In the first screenshot, You can see that after the * in the first times, all the following lines are off in syntax.
In the second screenshot, with the above row commented out, you can see that the syntax after the initial is off
In this last example I also tried to use the outline variables in a condition and ran into the same syntax problem after the first use
The < >
placeholder notation is no longer recommended in Karate, and Examples
columns are directly available as proper JS variables. If you have non-string types, you mark the column heading by appending a !
.
Here is the revised code that works fine, also refer documentation: https://github.com/karatelabs/karate#scenario-outline-enhancements
Feature:
Scenario Outline:
* def x = 1
* def output = x != null ? (100 + add) : null
* print 'output for add is ', output
* def output = x != null ? (100 - subtract) : null
* print 'output for subtract is ', output
* def output = x != null ? (100 * times) : null
* print 'output for times is ', output
* def output = x != null ? (100 / divide) : null
* print 'output for divide is ', output
* def output = add != null ? (100 + add) : null
* print 'output for add is ', output
* def output = subtract != null ? (100 - subtract) : null
* print 'output for subtract is ', output
* def output = times != null ? (100 * times) : null
* print 'output for times is ', output
* def output = divide != null ? (100 / divide) : null
* print 'output for divide is ', output
Examples:
| add! | subtract! | times! | divide! |
| 1 | 2 | 3 | null |
| 2 | 3 | null | 4 |