Skip to content

Instantly share code, notes, and snippets.

@mansilladev
Last active November 19, 2015 22:32
Show Gist options
  • Save mansilladev/53182bc37f04d3482d5b to your computer and use it in GitHub Desktop.
Save mansilladev/53182bc37f04d3482d5b to your computer and use it in GitHub Desktop.
Runscope Export Format - API tests sample export directly from a Runscope bucket. 2 tests with various simple assertions, scripted assertions, variables, and more.
[
{
"trigger_url": "https://api.runscope.com/radar/42117443-3e16-47d0-9e6f-499cc340c318/trigger",
"name": "Deck of Cards API Test",
"version": "1.0",
"exported_at": 1447971800,
"steps": [
{
"body": "",
"form": {},
"url": "http://deckofcardsapi.com/api/deck/new/shuffle/?deck_count={{numberOfDecks}}",
"variables": [
{
"source": "response_json",
"property": "deck_id",
"name": "currentDeckId"
}
],
"args": {},
"step_type": "request",
"auth": {},
"fragment": "",
"note": "Create new shoe with random number of decks",
"headers": {},
"assertions": [
{
"comparison": "equal_number",
"value": 200,
"source": "response_status"
},
{
"comparison": "equal_number",
"property": "remaining",
"value": "{{numberOfCardsExpected}}",
"source": "response_json"
}
],
"scripts": [],
"data": "",
"method": "GET"
},
{
"body": "",
"form": {},
"url": "http://deckofcardsapi.com/api/deck/{{currentDeckId}}/draw/?count={{numberToDraw}}",
"variables": [],
"step_type": "request",
"auth": {},
"fragment": "",
"note": "Draw random number of cards",
"headers": {},
"assertions": [
{
"comparison": "equal_number",
"value": 200,
"source": "response_status"
}
],
"scripts": [
{
"value": "// Parse response body JSON and stuff into data object\nvar data = JSON.parse(response.body);\n\n// Pull \"remaining\" from JSON payload of this request\nvar remaining = data.remaining;\n\n// Pull \"numberToDraw\" from our initial variables\nvar numberToDraw = variables.get(\"numberToDraw\");\n\n// Pull \"numberOfCardsExpected\" from the initial deck\nvar numberOfCardsExpected = variables.get(\"numberOfCardsExpected\");\n\n// Make assertion\nassert.ok((numberOfCardsExpected - numberToDraw) == remaining, \"Number of remaining cards is correct after draw.\");"
}
],
"method": "GET"
}
],
"description": "Create a deck, draw, shuffle, draw."
},
{
"trigger_url": "https://api.runscope.com/radar/67a16d5c-d245-40f3-b72c-8c7fe709e44b/trigger",
"name": "Runscope API > Regions Test",
"version": "1.0",
"exported_at": 1447971800,
"steps": [
{
"body": "",
"form": {},
"url": "https://api.runscope.com/regions",
"variables": [],
"args": {},
"step_type": "request",
"auth": {},
"note": "Fetch list of regions.",
"headers": {},
"assertions": [
{
"comparison": "equal_number",
"value": 200,
"source": "response_status"
},
{
"comparison": "equal",
"property": "meta.status",
"value": "success",
"source": "response_json"
},
{
"comparison": "is_less_than_or_equal",
"value": "1000",
"source": "response_time"
}
],
"scripts": [
{
"value": "// Parse out\nvar json = JSON.parse(response.body);\n\nvar regions = json.data.regions;\n\nassert.ok(regions.length >= 12,\"12 or more regions found.\");"
}
],
"fragment": "",
"data": "",
"method": "GET"
}
],
"description": "Test for the regions method. This method does not require authentication."
}
]
@mansilladev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment