100% Guaranteed Results


Testing go – # Exercise 9 Solved
$ 24.99
Category:

Description

5/5 – (1 vote)

In this exercise, you will use the HTTP test utilities available in Go to emulate a response from a real-world HTTP server. With the experience gained, you’ll be able to confidently write unit tests for production source code that would usually require an external endpoint.

1. Navigate to the directory `start`. You will find an existing Go project.
2. Inspect the functionality of the project.
3. Create a new test file named `http_test.go`.
4. Write a test case that uses `net/http/httptest` as a replacement to making a real HTTP call. The emulated HTTP call should respond with a HTTP 200 status code and the response body “Success!”.
5. Verify the expected response with appropriate assertions.
6. (Optional) Discuss: How would you implement a test case that returns a different status code than HTTP 200?

Reviews

There are no reviews yet.

Be the first to review “Testing go – # Exercise 9 Solved”

Your email address will not be published. Required fields are marked *

Related products