Writing API Tests Faster With AI and Github Copilot (Tutorial) | Serenity Dojo TV

Writing API Tests Faster With AI and Github Copilot (Tutorial) | Serenity Dojo TV

Introduction

In this section, John Ferguson Smart introduces the topic of using AI chat GPD and other AI tools to help with test automation. He explains that he will be showing how to write API tests using rest assured and serenity bdd, and how GitHub copilot can make the process simpler.

Using AI Chat GPD for Test Automation

  • John Ferguson Smart introduces the topic of using AI chat GPD and other AI tools to help with test automation.
  • He explains that he will be showing how to write API tests using rest assured and serenity bdd, and how GitHub copilot can make the process simpler.

Using GitHub Copilot for Writing API Tests

In this section, John Ferguson Smart explains what GitHub copilot is and how it can be used to speed up coding.

What is GitHub Copilot?

  • John Ferguson Smart explains what GitHub copilot is.
  • He mentions that it is a commercial tool that needs to be paid for but it's worth investing in as it speeds up coding.

Example API: London Transport Site

In this section, John Ferguson Smart introduces an example publicly available API from the London transport site which will be used to write some API tests.

Retrieving Bike Locations from TFL Website

  • John Ferguson Smart introduces an example publicly available API from the London transport site which will be used to write some API tests.
  • He mentions that there are many endpoints on this site such as air quality, taxi stands, tube trips etc., but they will focus on retrieving bike locations.
  • The API allows users to retrieve information about bike points in London, including specific bike points by name or the whole list of them.

Writing API Tests

In this section, John Ferguson Smart shows how to write API tests using rest assured and serenity bdd.

Defining Tests for Bike Point Endpoint

  • John Ferguson Smart starts by defining a test for the TFL endpoint that retrieves all bike points in London.
  • He uses GitHub copilot to speed up coding and defines the test as "should return all bike points".
  • He annotates it with "@Test" to make it a test.

Creating Bike Point Object

  • John Ferguson Smart creates a record for a bike point object which doesn't exist yet.
  • He uses GitHub copilot to define what properties he wants included such as ID, common name and place type.

Retrieving List of Bike Point Objects

  • John Ferguson Smart explains that he wants to retrieve a list of bike point objects from the TFL API.
  • He writes code to convert the retrieved data into objects and get some objects so that he can retrieve a list of bike point objects.

Conclusion

In this section, John Ferguson Smart concludes his demonstration on writing API tests using rest assured and serenity bdd.

Summary

  • John Ferguson Smart concludes his demonstration on writing API tests using rest assured and serenity bdd.

Creating a Bike Point API with Rest Assured

In this section, the speaker discusses creating a Bike Point API using Rest Assured. They add latitude and longitude to the API and write tests for it.

Adding Latitude and Longitude to the API

  • The speaker adds latitude and longitude to the Bike Point API by including float lat and long in their code.
  • The URL is not important at this stage.

Writing Tests with Rest Assured

  • The speaker mentions that they would usually create an API class to interact with the API on their behalf but will use Rest Assured directly for this tutorial.
  • They start writing tests using Rest Assured, beginning with a base URL of the TFL site and adding bike point as the endpoint.
  • They then add get, status code 200, extract Json paths, and get as a list of bike point classes.
  • The speaker asserts that bike points have size and uses assertJ matcher to check that each bike point has a non-empty common name.
  • They import assertJ manually because IntelliJ is not picking up the right assertions for some reason.

Making Test Reports More Readable

  • To make test reports more readable, the speaker replaces rest assured with Serenity rest in their code.
  • This generates an HTML file with documented output of the rest query.

Searching by Name

  • The speaker demonstrates how to search by name in the Bike Point endpoint by passing in a query parameter containing "Kensington" which returns all bike points containing that word.

Using GitHub Copilot for Rest Assured Tests

In this section, the speaker demonstrates how to use GitHub Copilot for Rest Assured tests.

Searching by Name

  • To search by name, the speaker suggests using the search terms and testing it.
  • The query parameter is the search term when get then the status code and we get the best back and we assert that the buy points is not empty it all maps the common buy Point common name search term you can see it's following the same sort of approach that
  • The speaker runs a test searching by Baker Street instead of Kensington.
  • This example shows how to use GitHub Copilot for Rest Assured tests.

Benefits of Using AI in Test Automation

  • By giving examples to GitHub Copilot, we can write a lot of code with minimal effort.
  • Although some tweaking may be necessary, this method produces correct rest assured code and serenity rest.
  • The speaker plans to demonstrate other ways to use GitHub Copilot in future videos.

There are no timestamps associated with some parts of this transcript.

Video description

How to write API tests faster using AI technology. Join me for this tutorial as I demonstrate how I test API's. Using the the Transport for London (TFL) website which is open to anyone, I will show you how you can use RestAssured and Serenity BDD to do API testing. We'll aslo look at GitHub CoPilot and how you can use this AI tool to help speed up your work. 🀯 NEED HELP? Want to excel as a Test Automation Engineer? Want your team to be a lean mean Agile Machine? Find out how Serenity Dojo can help: https://www.serenity-dojo.com/misc-449467991620807596030 πŸ’‘ START LEARNING with the Serenity Dojo online courses: https://expansion.serenity-dojo.com πŸ”₯ DON'T FORGET to grab your free Test Automation Roadmap: https://www.serenity-dojo.com/squeeze-page-498732241627288557956 ❀️ Enjoyed this video? Subscribe to our channel and hit the notification bell to never miss a new video β€” and let us know what advice you’d like to see next in the comments! β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Stay connected! πŸ”— LinkedIn: https://www.linkedin.com/groups/8961597/ Facebook: https://www.facebook.com/johnfergusonsmart Website: https://johnfergusonsmart.com/ #testautomation #apitesting #githubcopilot #serenitybdd

Writing API Tests Faster With AI and Github Copilot (Tutorial) | Serenity Dojo TV | YouTube Video Summary | Video Highlight