Getting started

What is mock.qa?

Mock.qa is a cloud service (SaaS) that provides a production-ready gRPC mocking server and supports both gRPC and gRPC-web protocols. It offers a rich request matching, response templating, and stateful scenarios. You can use a mock for prototyping, development, and testing.

Use cases

  • Front-end development
  • API prototyping
  • Manual testing
  • Automated testing
  • Education and research

Installation

Choose your plan on GitHub marketplace

Before using the mock.qa you need to set up a plan on GitHub Marketplace. Visit our page on GitHub Marketplace or see the detailed instruction here.

Quick start example

Lets consider a basic example of .proto file, which describes the Greeter service:

// Copyright 2019 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package demo.greet;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

And a configuration file .grpc.mock.qa.yaml that is placed in the root of your repository:

---
fileVersion: v1
serverName: Greet
protoFile: "/greet.proto"

# Incoming request matching is done in the order of definition,
# sequentially, from the first one to the last one,
# once match is found, the processing stops
calls: 

# First, we try to match a call to Joe
- method: SayHello
  request:
    body:
      Name: "Joe"
  response:
    body:
      Message: Hello Joe!
    status: OK

# Then, we try to match a call to Kelly
- method: SayHello
  request:
    body:
      Name: "Kelly"
  response:
    body:
      Message: Hello Kelly!
    status: OK

# And if no match, fall back to NotFound
- method: SayHello
  # "request" section is optional and may absent
  #   -  if "request" section is absent 
  #      then any call of the method is matched
  response:
    statusCode: NOT_FOUND
    statusDetails: Name not found

Use the Endpoint URL builder dialog to create an endpoint URL of the following format: https://[serverName→][repo→]<owner>.mock.qa. Configure your gRPC client to use this endpoint URL. Please note that the first call may take up to 30 seconds while your mock server is bootstrapping.

That's it, you now have configured your first mock server on mock.qa!