Skip to content

Commit

Permalink
Improvements in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jose.fernandez committed Aug 9, 2021
1 parent dcfd3b8 commit 48a754e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

/**
* Glue code of your applications. Use this class to create your own
* step definitions or cucumber hooks.
* step definitions or cucumber hooks. For more info check:
* https://cucumber.io/docs/cucumber/step-definitions/
* https://cucumber.io/docs/cucumber/api/#hooks
*
* For more info on how to create your own steps, you can check:
* https://github.com/veepee-oss/gingerspec/wiki/Creating-your-own-steps
*/
public class CustomStepsDefinition extends BaseGSpec {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@


/**
* This is an example on how to call an specific feature to be executed.
* This is the runner class responsible of running the included *.feature files in the project.
* Glue files can be specified in the {@link CucumberOptions} annotation
*
* Check out the utils.BaseTest class, there you can create TestNG hooks
* and more :)
* Also check out the {@link BaseTest} class, there you can create TestNG hooks and more :)
*/
@CucumberOptions(plugin = {
"json:target/CucumberRunnerIT.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/**
* This is an example of a simple TestNG test. For more information, you can check
* https://testng.org/doc/
*
* For more info on how to run your TestNG tests directly in Intellij IDEA check:
* https://github.com/veepee-oss/gingerspec/wiki/Setting-up-your-IDE#running-testng-test
*/
public class TestRunnerIT {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.lang.reflect.Method;

/**
* Use this class to define your own TestNG hooks
* Use this class to define your own TestNG hooks. For more info on TestNG hooks check:
* https://testng.org/doc/documentation-main.html#annotations
*/
abstract public class BaseTest extends BaseGTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
@rest
Feature: Testing a RestFull API
Feature: Testing a RestFull API example

The @rest annotation is necessary when using GingerSpec Rest steps, here is why:
https://github.com/veepee-oss/gingerspec/wiki/Hook-tags#rest-tag
This is an example of how to use the provided Rest steps of GingerSpec to test an API. For a
complete list of all steps, check https://github.com/veepee-oss/gingerspec/wiki/Gherkin-steps#rest-steps

This example uses https://jsonplaceholder.typicode.com, Fake Online REST API for Testing and Prototyping

Execute this test like this:
mvn verify -Dcucumber.filter.tags="@rest"
You can run this feature directly in Intellij IDEA, for more info check:
https://github.com/veepee-oss/gingerspec/wiki/Setting-up-your-IDE#running-cucumber-test
Or by running the following command in the terminal: mvn verify -Dcucumber.filter.tags="@rest"

You can check a more complete list of steps and examples at:
https://github.com/veepee-oss/gingerspec/wiki/Gherkin-steps#rest-steps
This example uses https://jsonplaceholder.typicode.com, Fake Online REST API for Testing and Prototyping

Scenario: A successful response with a valid body is returned
Scenario: Check a successful response with a valid body is returned
Given I securely send requests to 'jsonplaceholder.typicode.com:443'
When I send a 'GET' request to '/posts'
Then the service response status must be '200'
And I save element '$.[0].userId' in environment variable 'USER_ID'
Then '${USER_ID}' matches '1'

Scenario: Data in local file is altered using a datatable before sending
Given I securely send requests to 'jsonplaceholder.typicode.com:443'
When I send a 'POST' request to '/posts' based on 'schemas/mytestdata.json' as 'json' with:
| $.title | UPDATE | This is a test 2 |
Then the service response status must be '201'
And I save element '$' in environment variable 'response'
And 'response' matches the following cases:
| $.title | contains | 2 |
| $.body | contains | This is a test |
| $.userId | not equal | 2 |

Scenario: Add the body to be sent directly
Scenario: Send a POST request with body example
Given I securely send requests to 'jsonplaceholder.typicode.com:443'
When I send a 'POST' request to '/posts' with body
"""
Expand All @@ -42,5 +29,16 @@ Feature: Testing a RestFull API
"""
Then the service response status must be '201'

Scenario: Send a POST request with body from file
Given I securely send requests to 'jsonplaceholder.typicode.com:443'
When I send a 'POST' request to '/posts' based on 'schemas/mytestdata.json' as 'json' with:
| $.title | UPDATE | This is a test 2 |
Then the service response status must be '201'
And I save element '$' in environment variable 'response'
And 'response' matches the following cases:
| $.title | contains | 2 |
| $.body | contains | This is a test |
| $.userId | not equal | 2 |

Scenario: This is an example of a custom REST step
Given I verify that a successful response with a valid body is returned
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
@web
Feature: Testing basic functionality of a web page

The @web annotation is responsible of initializing the driver. Read more here:
https://github.com/veepee-oss/gingerspec/wiki/Running-Selenium-tests
This is an example of how to use the provided Selenium steps of GingerSpec to perform actions on a web page. For a
complete list of all steps, check https://github.com/veepee-oss/gingerspec/wiki/Gherkin-steps#selenium-steps

You can run this feature using the following command:
mvn verify -Dcucumber.filter.tags="@web"

You can check a more complete list of selenium steps and examples at:
https://github.com/veepee-oss/gingerspec/wiki/Gherkin-steps#selenium-steps
You can run this feature directly in Intellij IDEA, for more info check:
https://github.com/veepee-oss/gingerspec/wiki/Setting-up-your-IDE#running-cucumber-test
Or by running the following command in the terminal: mvn verify -Dcucumber.filter.tags="@web"

Scenario: Fill the form and click the submit button
Given I go to 'http://demoqa.com/text-box'
Expand Down

0 comments on commit 48a754e

Please sign in to comment.