Aug 15, 2023
Over the past few weeks we’ve been walking you through some of the great use cases for Mocker, the first of our Kubernetes testing tools in our VS Code extension, Kubernetes Test Toolkit.
Today I want to walk you through its powerful gRPC proxying capability. You can easily mock a subset of the methods in an endpoint, while directing others to the live service in your cluster, enabling more realistic, more meaningful tests.
Imagine you’re developing an e-commerce website with a microservice architecture. Today, we’ll focus on the product service catalog service, responsible for displaying products to customers.
Say we want to mock the ListProducts and SearchProducts methods using Mocker. By defining mock data, we simulate various product scenarios, ensuring our frontend components and layouts work as expected.
However, when it comes to fetching real product details for individual product pages, we want the latest information. We configure Mocker to proxy the GetProduct method to the live service by setting proxy equal to true. From now on, all requests are forwarded to the live service.
Once we’re done editing, we save the changes and deploy the mocks. With Mocker in place, our frontend seamlessly interacts with mocked methods while retrieving real data for product searches.
This proxy functionality helps you streamline your development with gRPC proxying. Mocker is free to use and available now on the VSCode extension marketplace.
Coming soon – Tester, the perfect test client complement to Mocker. Tester makes it easy for devs to go beyond unit testing and generate and run complex scenarios for comprehensive services testing. Sign up here to be among the first to hear when we add this new toolkit capability!