Skip to content

datjan/testing-fitnesse-myapifixtures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

testing-fitnesse-myapifixtures

Introduction

These are FitNesse (http://fitnesse.org) Fixtures für Rest Api Testing included in an Eclipse Java project. The project requires JavaSE-1.8

Actual supported formats:

  • Json

FitNesse import fixtures

Use this to import the fixture to your test: (Don't forget to adjust the path)

classpath: /Users/jan/Documents/FitNesse/fitnesse-standalone.jar
classpath: /Users/jan/Documents/eclipse-workspace/MyApiFixtures/bin

variable defined: TEST_SYSTEM=fit 

|Import       |
|myApiFixtures|

Simple usage

A simple request include three mandatory steps.

Init Request:

!|My Api Request Init                              |
|Method|Baseurl              |Path           |Init?|
|GET   |http://192.168.178.51|/mockme/api.php|ok   |

Send Request:

!|My Api Send                                      |
|Send Request?|Get Status Message?|Get Status Code?|
|ok           |OK                 |200             |

Validate Response:

!|My Api Response Body|
|Get Body?            |
|                     |

Advanced usage - request

These Fixtures can be used to extend the test possibilities.

Add body to request

!|My Api Request Body |
|Body           |Init?|
|{"type":"test"}|ok   |

Add body to request from file

!|My Api Request Init                                                                                                                                    |
|Method|Baseurl              |Path           |Body File Path                                                                                       |Init?|
|POST  |http://192.168.178.51|/mockme/api.php|/Users/jan/Documents/FitNesse/FitNesseRoot/FitBackoffice/MyApiFixturesExampleSuite/SimpleRequest.json|ok   |

Add header to request

!|My Api Request Header                               |
|Name         |Value                            |Init?|
|Content-Type |application/x-www-form-urlencoded|ok   |
|Authorization|Bearer Token                     |ok   |

Add parameter to request

!|My Api Request Url Parameter|
|Name      |Value      |Init? |
|type      |test       |ok    |
|email     |[email protected] |ok    |
|password  |123abc!    |ok    |

Use symbol in Body

!|My Api Request Body        |
|Body                  |Init?|
|{"type":"#{req_type}"}|ok   |

!|My Api Request Variables|
|Name     |Value=   |Init?|
|req_type |sym_type |ok   |

Advanced usage - response validation

These Fixtures can be used to validate the response.

In case of this is the response:

{"success":true,"basicdata":{"pointofsales":[{"id":"1","name":"Ebay","number":123},{"id":"2","name":"Ebay Kleinanzeigen","number":456},{"id":"3","name":"WooCommerce","number":789}],"plainarray":["bernd","nils","harry"]}}

This could be the validation

!|My Api Response Body Validator                                                                                     |
|Parser|Identifier                                    |Value?                                             |=Value?   |
|json  |root.success                                  |true                                               |res_symbol|
|json  |root.basicdata.pointofsales[1].name           |Ebay Kleinanzeigen                                 |res_symbol|
|json  |root.basicdata.pointofsales[id=3].name        |WooCommerce                                        |res_symbol|
|json  |root.basicdata.pointofsales["id"=3].name      |WooCommerce                                        |res_symbol|
|json  |root.basicdata.pointofsales[name="Ebay"].id   |1                                                  |res_symbol|
|json  |root.basicdata.pointofsales["name"="Ebay"].id |1                                                  |res_symbol|
|json  |root.basicdata.pointofsales[number=456].name  |Ebay Kleinanzeigen                                 |res_symbol|
|json  |root.basicdata.pointofsales["number"=456].name|Ebay Kleinanzeigen                                 |res_symbol|
|json  |root.basicdata.pointofsales[number="456"].name|Ebay Kleinanzeigen                                 |res_symbol|
|json  |root.basicdata.pointofsales[1]                |{"number":456,"name":"Ebay Kleinanzeigen","id":"2"}|res_symbol|
|json  |root.basicdata.pointofsales["number"=456]     |{"number":456,"name":"Ebay Kleinanzeigen","id":"2"}|res_symbol|
|json  |root.basicdata.plainarray[1]                  |nils                                               |res_symbol|
|json  |root.basicdata.pointofsales[count]            |3                                                  |res_symbol|
|json  |root.basicdata.plainarray[count]              |3                                                  |res_symbol|

Usage of symbol in value

!|My Api Response Body Validator|
|Parser  |Identifier  |Value?=  |
|json    |root[1]     |sym_name |

Usage of symbol in identifier

!|My Api Response Body Validator        |
|Parser|Identifier  |Variable=   |Value?|
|json  |root[#{var}]|sym_position|nils  |

Examples

You can find more examples within the "MyApiFixturesExampleSuite"

Releases

No releases published

Packages

No packages published

Languages