...
Info |
---|
The examples provided in this page are used to explain how to write the fixture for the SetupInterpreter. |
7. Advanced
Do With - Table, Bullet List or Number List example
supports the expression of rules in table format, bullet list format or number list format. The following examples are equivalent and will yield the same results when executed.
It is important to note that the table and bullet list examples are not executable since the import com.greenpepper.samples.fixture.bank and do with bank rules cannot be specified twice in the same page. Even though it is possible to change between the two methods in the same page, you must keep in mind that the tests are executed in the same system under development. So it is not necessary to re-specify the same rule in the page.
Table
import |
com.greenpepper.samples.application.bank |
do with | bank | ||||||
open | checking | account | 12345-67890 | under the name of | Spongebob | Squarepants | |
check | that balance of account | 12345-67890 | is | $0.00 | |||
deposit | $100.00 | in account | 12345-67890 | ||||
check | that balance of account | 12345-67890 | is | $100.00 |
Bullet List
- import
- com.greenpepper.samples.application.bank
- do with bank
- open checking account 12345-67890 under the name of Spongebob _Squarepants
- deposit $100.00 in account 12345-67890
- check that balance of account 12345-67890 is $100.00
Number List
- import
- com.greenpepper.samples.application.bank
- do with bank
- open checking account 12345-67890 under the name of Spongebob _Squarepants
- deposit $100.00 in account 12345-67890
- check that balance of account 12345-67890 is $100.00
Object-Graph Navigation Language (OGNL)
has an extension to supports OGNL expressions. Here are some examples, using the Calculator system:
< , <= , > , >= , and , or | supports these simple mathematical expressions. Use the question mark to specify the position of the value returned by the system. For example, if the expected value should be greater than 15, you will write "? > 15" in the cell. |
---|---|
+ , - , / , * | performs simple operations as a resulting expression. To specify you want to evaluate those operations prior to the comparison, insert an equal sign at the beginning of the operation (ex: =4+1-3). |
rule for | calculator | |||
x | y | sum? | product? | quotient? |
6 | 2 | 8 | 12 | 3 |
7 | 0 | 7 | 0 | error |
40 | 50 | 90 | ? > 100 | |
4 | -5 | ? <= 0 | -20 | ? <= 0 |
3 | 3 | ? < 1 or ? > 4 | ? >= 9 and ? < 12 | "1" |
4 | 2 | =4+2-0 | =2*4 | =4/2 |
To use this extension, you need to specify the fixture factory as com.greenpepper.extensions.ognl.OgnlSupport and add the greenpepper-extensions-ognl-x.x.jar and ognl-x.x.x.jar (that can be found here http://www.greenpeppersoftware.com/nexus/content/groups/public/) to the classpath of the SUT.
Information Tag
Information tags
When a document is executable, will try to interprete all the supported forms of the document body.
This brings some issues when we need to insert information as Tables or Bullet lists, for example.
To avoid undesired interpretation of forms, we can use the Information tags.
This tag will force to skip all forms between the Begin Info and End Info tags.
Here is an example:
Begin Info |
This table | shouldn't be | interpreted |
- This bullet list
- shouldn't be
- interpreted either
End Info |
We won't see any coloration of the above table or bullet list after execution of this document.
will restart the interpretation of the document from from this point.
Rule for | Calculator | |
---|---|---|
x | y | sum? |
1 | 2 | 3 |
Info | ||
---|---|---|
| ||
If the End Info tag is omitted all the body content of the document after the Begin Info tag, will be skipped. |
Commented forms
Comment tag
We can decide for some reason that a test shouldn't be executed. Instead of deleting the test from the document, we can comment it. This will force to skip the test.
The test should be preceded by the tag Comment.
Here are some examples:
Test using the bullet list form.
- Comment
- My bulletlist test to skip
Test using the Table form.
Comment | |
My table | to skip |
We won't see any coloration of the above table or bullet list after execution of this document.
will restart the interpretation of the document from from this point.
Rule for | Calculator | |
---|---|---|
x | y | sum? |
1 | 2 | 3 |