DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Cypress API Testing: A Detailed Guide
  • Which API Testing Strategy Should You Use? Manual vs. Automated
  • Cypress.io — The Rising Future of Web Automation Testing
  • Spring Boot Delete User Details API Test Client Using Rest Assured | API Testing Using Rest Assured

Trending

  • Leveraging FastAPI for Building Secure and High-Performance Banking APIs
  • Supercharge Your Software Development Journey With DevOps, CI/CD, and Containers
  • The Ultimate Guide to API vs. SDK: What’s the Difference and How To Use Them
  • Harnessing the Power of In-Memory Databases: Unleashing Real-Time Data Processing
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. API Testing With Runscope

API Testing With Runscope

If you're using APIs, you need to test well. Here's a guide to testing APIs with Runscope, with a breakdown of creating a bucket and making a test.

Lorna Mitchell user avatar by
Lorna Mitchell
·
Jan. 10, 16 · Tutorial
Like (2)
Save
Tweet
Share
8.75K Views

Join the DZone community and get the full member experience.

Join For Free

i work with a lot of apis and i really appreciate good tools. lately i've been really enjoying using runscope for testing and monitoring my apis so i thought i'd share how i work with this tool, which has a great one-person free tier *and* the ability to import/export tests so if you need to work with a team with just the free tier (the examples here are from an open source project which is an obvious use case where it's hard to fund tools), it's clunky but doable. the idea here is just to show you around how to create your own api tests with runscope (and also to write down what i did so i can point both my future self and others at this!)

create a bucket

first up, create a "bucket"...i'd call this a "test suite" in any other setting. it's just a place to keep things really but it has some really handy features:

  • you can set up variables (such as a base_url ) in the bucket which are then used by all your tests. this makes it trivial to make changes and run the tests again, for example against another platform
  • you can also get your tests to use the bucket settings for which locations to run from and again, this makes it easy to change
  • once you've written some tests, you can trigger all the tests in a bucket by using a specific url

create a test

i'm just creating a simple test, which points at https://test.api.joind.in and makes sure that there's a "hot events" url listed, and that calling it returns sensible data.

create a runscope test

this just shows that i have the bucket-wide settings selected, and a test with two steps - first to get the main api page, and then to get the hot events page.

the {{base_url}} is set in the bucket-wide settings, which are selected in the top-right hand side of the test (this took me ages to find the first time), and i use it to define what to call:

create the first api call

as well as setting some "assertions" that your response must fulfil (more on those in a moment), you can grab "variables" from one response to use in the next request. in this example, i want to get the hot-events property so i can then call it (this is hypermedia; the url might change).

capture variables for later use

with that url captured, my next test simply calls it. both steps have some assertions that the responses must be compliant with - here are the ones i have added to check the response of the second step:

assertions about what the api should return

if any of these assertions fail, the test will be marked as failed. when working on either capturing variables or writing assertions, look out for the "last response data" accordion piece, it's super-helpful to be able to see what came back last time!

running the tests

i can run tests individually (look for the "save and run" buttons at the top of the edit test screen) and the history of results are displayed in the sidebar (as you can see in my screenshots, i was still working on getting this test passing until shortly before i took the screenshot!), you can also run tests all together and with different settings - that's a blog post for another day perhaps.

runscope can run your tests on a schedule, and be set up with alerts for how to let you know if something fails. in addition to the pass/fail data, it also stores information about how long each test takes, which can be really helpful if you're suddenly seeing timeouts to be able to realise that your api got slower two deploys ago or something.

API Testing API testing

Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Cypress API Testing: A Detailed Guide
  • Which API Testing Strategy Should You Use? Manual vs. Automated
  • Cypress.io — The Rising Future of Web Automation Testing
  • Spring Boot Delete User Details API Test Client Using Rest Assured | API Testing Using Rest Assured

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: