This document discusses automated testing and the Minosse testing framework. It provides instructions on setting up Minosse and using its generic steps for testing APIs. Examples are given of writing Cucumber feature files using Minosse steps to check HTTP requests and validate response properties. Best practices for writing good feature files are also outlined, such as having single responsibility tests and using exploratory testing.
6. The new tester
Program languages
• Groovy
• JAVA
• NodeJS
• Ruby
https://www.flickr.com/photos/jdhancock/
7. Easy to switch for testers between projects
• One language for test automation across projects
• Test written in a uniform style across projects
Problems we solved
Easy to adapt for new testers
• Tests written in a readable language for a techie person
• No scripting skills required to write automated tests
Easy life for developers
• Test implementation code is written once
• Bugs and fixes in one place
8. Agenda
• Why and how Minosse is developed
• How to create automated checks in Minosse (CucumberJS)
• Thoughts behind writing great feature files
11. Generic set of common steps for testingAPI
(ab)-use CucumberJS
• Property steps
• HTTP steps
• Debug steps
Minosse
12. Load testdata
• Given I set property foo to testdata foo
Setting a property
• Given I set property foo of request body to number 4
Remove a property
• Given I remove property foo
Property setting steps
13. Set the request body
• Given I set the request body to property foo
Set a request header
• Given I set the request header bar with value foo
Set the request content type
• Given I set the request header Content-Type with value multipart/formdata
Save the response body
• Given I set property foo to the response body
Http steps Set requests and save response body
14. Send a request
• Given I send a POST request to /foo
Sending an HTTPS request
• Given I secure the connection with certificate certificate.crt and with key
keyFile.key
Check the response code
• Given the response status code is 200
Http steps sending a request and check
15. Checking if property does not exist
• Given I check property foo of response body does not exist
Checking the value of a property
• Given I check property foo of response body equals number 4
Checking the type of a property
• Given I check property foo of response body has type number
Checking the format of a property
• Given I check property bar has format email
Property checking steps
19. Setup your own environment
Install instructions
1. Install NodeJS
2. Clone the api repository `git clone git@github.com:aredo/restcountries.git`
3. Checkout the release 0.1.0 `git checkout tags/0.1.0`
4. cd restcountries && npm install minosse cucumber
20. Or we made an environment for you
Install instructions
1. Ask Pascal or Valerio the USB
2. Copy the content somewhere in your machine
3. Import the machine in VirtualBox
You can also download the machine here:
https://goo.gl/WKXOFk
25. Scenario: Calling Get should return a 200 status code
Given I send a GET request to /
When the response status code is 200
Assignments 1 add a debug step
Then DEBUG I print property response body
For handouts see https://goo.gl/OyJuZD
26. Scenario: Calling Get should return a 200 status code
Given I send a GET request to /
When the response status code is 200
Then DEBUG I print property response body
And I check
Assignments 2 add a check on the response
property message of response body equals string Welcome buddy!
27. Scenario: Calling Get on endpoint /incorrect should return a 404 status code and
the message Sorry, that page does not exist
Given I send a GET request to /incorrect
When the response status code is 404
And I check
Assignments 3 check a specific status
property message of response body equals string Sorry, that page does not exis
28. Scenario: Calling Get on endpoint api/v1 should return a 200 status code and I
check multiple properties.
Given I send a GET request to /api/v1
When the response status code is 200
And I check
Assignments 4 check a specific value
property res.body[0].name equals stringAfghanistan
29. Scenario: I want to show my custom steps
Given I want to create a custom step
Assignments 5 create a custom step
30. Agenda
• Why and how Minosse is developed
• How to create automated checks in Minosse (CucumberJS)
• Thoughts behind writing great feature files
31. What the testers do in the project
Create test ideas
Review documentation
Review tests
Create automated
testsMaintain tests
Exploratory testing
Review reports
33. •Created by the team.
•Self verifying data for files en test….
•1 test should test 1 thing (single responsibility pattern).
•Exploratory testing is mandatory for a good check
•What is implemented is tested. => Test should always reflect implementation.
•We use Coverage Report to measure the test coverage. To train ourselves in
creating better test.
•Everything is reviewed by the someone in the team or by an other team
Writing a good feature file
34. @collect-active
Feature:As a user I want to collect and receive stamps with bonus stamp offers
@BSO
Scenario Outline:As a user I want to collect and receive stamps with bso
Given testdata collect_active is stored as collect
........
When I send a POST request to /…/………………/active
Then the response status code is 200
And check property transactionId of response body is property transactionIdentifier
And check property newBalance of response body is number <newBalance>
And check property mutation of response body is number <mutation>
Examples:
|amountSpent |bso |value |newBalance |mutation |
|10 |Bso1Stamps |1 |2 |2 |
|10 |Bso100Stamps |1 |101 |101 |
|20 |Bso1Stamps |7 |9 |9 |
|10 |BsoLimitedLife |1 |2 |2 |