Your SlideShare is downloading. ×
0
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
SPRAT - Spreadsheet API Tester
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

SPRAT - Spreadsheet API Tester

1,313

Published on

SPRAT is a test tool, which uses spreadsheets to define tests and then runs those tests against specified APIS.

SPRAT is a test tool, which uses spreadsheets to define tests and then runs those tests against specified APIS.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,313
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • An example of a simple JSON API is github repo search
  • Give it a query param of a search term
  • And you get JSON (actually much more
    Btw – rate limited!
    )
  • Key/value pairs
    Define api, host
    Get back started/finished, status
    Parameters (comma sep)
    Ignore (comma sep)
    Aliases
    Colour coding (conditional formatting
  • Transcript

    • 1. SPRAT Spreadsheet API Tester Julian Higman
    • 2. Julian Higman ● Freelance developer ● PHP/Ruby/Linux/etc ● Agile (XP) ● Tests
    • 3. Sprat : Spreadsheet API Tester ● Why ● What ● How ● WTF?
    • 4. Background ● KnowMalaria ● Prescription System ● Antimalarials, and now vaccines
    • 5. KnowMalaria ● Data-centric app ● Domain experts ● People might die
    • 6. Testing ● Unit test ● Integration test ● Functional test ● Live monitoring ● ...Exo-test?
    • 7. Manual Test Scenarios
    • 8. Manual Test Scenarios
    • 9. Requirement ● Non-programmers ● Complex test scenarios ● Running outside of the build ● Scheduled or On Demand ● Feedback
    • 10. Idea ● Use spreadsheets as test input ● Expose testable functions as APIs ● “Run” button
    • 11. Architecture
    • 12. APIs ● RESTful (well, GET, at least) ● Return JSON
    • 13. Github API https://api.github.com/search/repositories?q=sprat
    • 14. { "total_count": 3, "items": [ { "id": 1898910, "name": "sprat", "full_name": "hinathan/sprat", "html_url": "https://github.com/hinathan/sprat", "description": "A simple PHP+REST API toolkit" }, { "id": 9957180, "name": "sprat", "full_name": "jhigman/sprat", "html_url": "https://github.com/jhigman/sprat", "description": "Spreadsheet API Test Runner" }, { "id": 1840441, "name": "Spratly", "full_name": "rgv151/Spratly", "html_url": "https://github.com/rgv151/Spratly", "description": "Backend & Development Kit for Laravel 4" } ] }
    • 15. JSONPath ● $.store.book[0].title ● $['store']['book'][0]['title'] ● $.store.book[(@.length-1)].title ● $.store.book[?(@.price < 10)].title http://goessner.net/articles/JsonPath/
    • 16. Tests id q $.total_count 1 sprat 3
    • 17. Tests id q $.total_count $.items[0].description 1 sprat 3 A simple PHP+REST API toolkit 2 mackerel 7 Object storage system 3 shark 511 Hive on Spark
    • 18. Sprat spreadsheet
    • 19. Config
    • 20. Menu
    • 21. Simplification : Hashes for API response { “key1” : “val1”, “key2” : “val2” } expectation columns called “key1”, “key2” will be interpreted as “$.key1”, “$.key2”
    • 22. Special case : Arrays id country 1 Albania 2 Angola 3 Antartica 4 Aruba Cholera Diptheria Hep A Y Y Y Y Y Y
    • 23. Array API /api/diseases?country=Aruba [“Diptheria”, “Hep A”]
    • 24. Array spreadsheet
    • 25. Sprat server ● Ruby ● Sinatra ● Redis ● Resque
    • 26. Invoke Sprat POST to /jobs params: spreadsheet = <spreadsheet name> worksheet = <worksheet name> host = <host name>
    • 27. Read and write spreadsheets Ruby Gem : https://github.com/gimite/google-drive-ruby session = GoogleDrive.login("username@gmail.com", "mypassword") ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0] ws[2, 1] = "foo" ws[2, 2] = "bar" ws.save()
    • 28. In the spreadsheets.. ● Google Apps Script (basically Javascript) ● Menus ● URL Fetch Service ● PDFs ● Emails ● Triggers
    • 29. Add menu items function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var menuEntries = [ {name: "Run tests", functionName: "runThisSheet" } ]; ss.addMenu("Test Runner", menuEntries); }
    • 30. Invoke test runner var payload = { "spreadsheet" : “My Test Spreadsheet”, "worksheet" : “Worksheet 1”, "host" : “api.test.com” }; var options = { "method" : "POST", "payload" : payload }; var response= UrlFetchApp.fetch(“http://sprat.testrunner.org”, options); var content = response.getContentText();
    • 31. Create PDF var ss = SpreadsheetApp.getActiveSpreadsheet(); var file = DriveApp.getFileById(ss.getId()) var pdf = file.getAs(MimeType.PDF); var folder = DocsList.getFolder(“SpratPDFs”); var file = folder.createFile(pdf);
    • 32. Send Email MailApp.sendEmail( “sprat-user@sprat.org”, “Your latest Sprat report”, “Please see attached”, {attachments:[pdf]} );
    • 33. Triggers
    • 34. Demo ● Github ● Travis ● Heroku ● Redis Cloud
    • 35. So how's it working for us? ● 10 spreadsheets ● 2000 tests ● Nightly emails
    • 36. Other benefits ● Step-change in rate of data tests ● TDD by users ● Pair-programming data changes ● Diagnosing problems ● Versioning ● Authentication ● API-first design
    • 37. Limitations ● GET ● JSON ● No custom headers ● Assumes HTTPS endpoint ● JSONPath ● Error responses ● Setup/teardown
    • 38. Future ● Matchers ● OAuth ● Standards ● JSON Schema ● Continuous Integration
    • 39. Questions ● Anyone similar problem? ● Anything that already exists? ● Any glaring problems? ● Any suggestions for improvements? ● Anyone want to try it?
    • 40. KTHXBYE! http://jhigman.github.io/sprat/ @jhigman @staringskyward

    ×