Other steps - veepee-oss/gingerspec GitHub Wiki
check these examples:
For a complete list of steps definitions related to other useful functionality, please check the corresponding class in the javadoc here
Saves value for future use.
Given I save '12345678' in variable 'password"'
Static wait used to halt the execution of the feature for a given amount of seconds. After the time completes, the remaining steps in the feature are executed
Example
When I wait '10' seconds
This step is commonly used to wait for a background operation to complete, so next steps wont return false negatives.
Bad, checking immediately if the page contains an element
Given I securely browse to 'mypage.com:80'
And I browse to '/login'
Then '1' elements exists with 'xpath://*[@id="menus"]/div/div/ul/li[5]'
Good, providing a time to wait for all elements in the page to load
Given I securely browse to 'mypage.com:80'
And I browse to '/login'
Then I wait '3' seconds
Then '1' elements exists with 'xpath://*[@id="menus"]/div/div/ul/li[5]'
This gives the system enough time to load all elements in the DOM, making less likely to return an error when looking for a specific element.
This step completely halts the operation of the feature for the given time and could reduce performance (increase the feature execution time) if used too frequently or if the time used is unnecessarily large. Try to use a reasonable time in your tests, or in the case of cucumber related scenarios, there is a much better alternative to the static wait: The waiting with pooling step
Checks if an exception is/is not thrown during the execution of the previos step. It can also check the exception class and the message of the exception
Checking if any exception is thrown
When I execute a jdbc select 'SELECT count(*) FROM crossdataTables''
Then an exception 'IS NOT' thrown
Checking if not exception is thrown
Given I execute 'CREATE TABLE newCatalog.newTable'
Then an exception 'IS' thrown
Checking if a particular exception is thrown
When I delete the stream 'testStreamACK0'
Then an exception 'IS' thrown with class 'PrivaliaEngineConnectionException' and message like 'Acknowledge timeout expired'
Creates a JSON file in the /target/test-classes directory of the project with the specified name. This file can later be referenced using $(pwd)/target/test-classes/fileName. This steps receives a datatable with a list of all modifications to be performed in the seed file (ADD, REPLACE, APPEND, ADDTO, etc)
You can specify a seed file that uses the contents of another file to create a single merged file with ADDTO. For example
Given I create file 'testCreateFilePlain.json' based on 'schemas/testCreateFile.json' as 'json' with:
| $.key2 | ADDTO | ${file:UTF-8:src/test/resources/schemas/testCreateFileReplacePlainText.json} | string |
Will create a file with name testCreateFilePlain under /target/test-classes, using'schemas/testCreateFile.json' as template, changing the value $.key2 with the contents of schemas/testCreateFileReplacePlainText.json as string
schemas/testCreateFile.json |
schemas/testCreateFileReplacePlainText.json |
resulting file (testCreateFilePlain.json) | ||
|
new_string_value |
|
---|
The library will try to cast the contents of the schemas/testCreateFileReplacePlainText.json to the specified type:
- string: like in the abode example
- boolean: true|false
- object: A JSON object
- number: numeric type value
- array: a representation of an array ( ["new_value_1", "new_value_2"])
You can also use ADDTO to reference other created files, for example
Given I create file 'testCreatePrevious.json' based on 'schemas/testCreatePreviousFile.json' as 'json' with:
| $.key_previous_1 | UPDATE | value_previous_2 | string |
Then I create file 'testCreatePreviousFinal.json' based on 'schemas/testCreateFile.json' as 'json' with:
| $.key2 | ADDTO | ${file:UTF-8:target/test-classes/testCreatePrevious.json} | object |
First step will create a file testCreatePrevious.json under /target/test-classes, using 'schemas/testCreatePreviousFile.json' as template, changing the value $.key_previous_1 with 'value_previous_2' as string
schemas/testCreatePreviousFile.json |
UPDATE |
Final result (testCreatePrevious.json)
|
||
---|---|---|---|---|
|
$.key_previous_1 -> value_previous_2 |
|
The second step will use the contents of the previously created testCreatePrevious.json (under /target/test-classes), and will insert it into $.key2 of 'schemas/testCreateFile.json'
schemas/testCreateFile.json |
/target/test-classes/testCreatePrevious.json |
/target/test-classes/testCreatePreviousFinal.json |
|||
---|---|---|---|---|---|
|
|
|
Read the file passed as parameter, perform the modifications specified and save the result in the environment variable passed as parameter
Using a json file and updating its contents
Given I read file 'schemas/testCreateFile.json' as 'json' and save it in environment variable 'myjson' with:
| $.key1 | UPDATE | new_value | n/a |
| $.key2 | ADDTO | ["new_value"] | array |
Reading a plain text file and editin its contents
Given I read file 'schemas/krb5.conf' as 'string' and save it in environment variable 'mystring' with:
| foo | REPLACE | bar | n/a |
Read the file passed as parameter and save the result in the environment variable passed as parameter. Unlike the previos example, if no modifications are necessary in the file, there is no need to specify a datatable with modifications
Example
Given I read file 'schemas/testCreateFile.json' as 'json' and save it in environment variable 'myjson'