Member-only story

Testing GraphQL APIs, Part 2: Run frequently in a Continuous Testing Server

Stabilising the tests and setting them up in a Continuous Testing server.

Zhimin Zhan
6 min readNov 27, 2022

A repost of my daughter’s article with permission.

In Part 1, I created five basic GraphQL API tests in Ruby. They worked but were not good enough as test execution is 100% reliable.

I used specific IDs in test scripts, which might work fine the first time around. However, the situation change with upcoming executions, the ID might be taken (duplicate error for CREATE), or no longer exist (causing READ, UPDATE and DELETE operations to fail). Also, I didn’t clean up after my tests in Part 1.

Furthermore, as a habit, I run automated tests in a Continuous Testing server. To do that, I must stabilize my tests first: can run them successfully multiple times. In this article, I will revise the tests written in Part 1 and set up running them in a CT server, as regression testing.

Stabilize Tests

1. LIST all records

No changes from Part 1:

  it "List all continents" do
uri = URI.parse("https://countries.trevorblades.com/")
request = Net::HTTP::Post.new(uri)
request.content_type =…

--

--

Zhimin Zhan
Zhimin Zhan

Written by Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.

No responses yet