QA Interview Hub · Knowledge base · Quizzes · Українська

API

gRPC

gRPC: what it is and how it differs from REST

gRPC is a remote procedure call framework: a client calls a service method almost like a local function, and the contract lives in a .proto file. The transport is HTTP/2 and the default message format is Protocol Buffers: binary, compact and strictly schematised. The result is decided not by the HTTP status but by grpc-status in the trailers, so QA needs the schema, a generated client and a check of that status.

API · gRPC

A team moves from REST to gRPC. What changes for tests and for the contract?

The morning after a migration: curl against the new service returns an unreadable binary stream or a protocol error, and Postman asks for a .proto upload instead of a URL with a GET. Tests written as "an HTTP request and JSON in the response" do not work here. The lesson explains what gRPC is, how its model differs from REST and what follows from that for QA.

How it works and why it is designed so

gRPC is a remote procedure call (RPC) framework: a client calls a service method almost like a local function. There is one contract, described in a .proto file; the client and the server stubs for many languages are generated from it. The transport is HTTP/2, the default message format is Protocol Buffers: binary, compact, with a strict schema. The "schema before code" decision removes a whole class of errors: the two sides cannot disagree on a field name or type because both are generated from one file.

syntax = "proto3";
package shop.v1;

service OrderService {
  rpc GetOrder (GetOrderRequest) returns (Order);
  rpc WatchOrders (WatchRequest) returns (stream Order);
}

message GetOrderRequest { string id = 1; }
message Order {
  string id = 1;
  int64 total_cents = 2;
  Status status = 3;
}
enum Status { STATUS_UNSPECIFIED = 0; PAID = 1; SHIPPED = 2; }

From schema to a call

The .proto filethe single source of the contractCode generationprotoc or buf: client and stubsA method callProtobuf in HTTP/2 frames
Figure 1. The contract lives in one file, the rest is generated.

The binary format and HTTP/2 multiplexing (many streams in one connection) give smaller messages and lower latency than JSON over HTTP/1.1. The price: a message cannot be read by eye, and any interaction needs the schema.

Worked example: the same call in two models

In REST an order is read like this:

GET /orders/42 HTTP/1.1
Authorization: Bearer <token>

HTTP/1.1 404 Not Found

gRPC has no equivalent request line: the method OrderService/GetOrder is invoked with a POST to the path /shop.v1.OrderService/GetOrder, and the result is decided not by the HTTP status but by grpc-status in the trailers (details in the lesson on statuses). In practice that means three changes in the work:

  • Manual checks go through grpcurl, Postman or Insomnia, and they need the schema: from a .proto file or through server reflection.
  • Automated tests are written on a generated client: a mismatch with the schema is caught by the compiler, not by a late run.
  • The contract is now a file that can be checked automatically: a linter and a backward-compatibility check in CI.

Limits and alternatives

REST and gRPC: what differs

REST

Resources and verbs

JSON you can see in a browser or curl. The schema (OpenAPI) is optional and can drift from the implementation. Works in a browser directly.

gRPC

Method calls

Binary Protobuf over HTTP/2. The .proto schema is mandatory and typed. Streaming out of the box. A browser needs grpc-web or Connect.

Figure 2. Two legitimate options: the choice depends on clients and latency requirements.
  • Browser. Browser JavaScript cannot control HTTP/2 frames and trailers, so direct gRPC is unavailable. Solutions: grpc-web through a proxy (for example Envoy), the Connect protocol or gRPC-Gateway with REST/JSON on top of the service.
  • GraphQL gives the client an arbitrary query shape against one endpoint; gRPC fixes the set of methods and shapes in advance.
  • Where it is used. Internal microservice calls, low latency, streaming, mobile clients, teams with different languages. Public APIs for third-party developers more often stay REST.

Common mistakes

  • Expecting an HTTP code as the result: almost always a 200 arrives and the error sits in grpc-status.
  • Writing tests on hand-written JSON wrappers instead of the generated client: mismatches with the schema come back.
  • Not testing the gateway (grpc-web, gRPC-Gateway): it has its own mapping of statuses to HTTP and its own JSON serialisation.

Check yourself

A team says: "we described everything in OpenAPI, so we do not need a .proto". Is that possible for gRPC?

Answer

No. The gRPC client and server are generated from .proto, and it determines how messages are encoded into bytes. OpenAPI describes HTTP/JSON and is not related to a gRPC service, except for a gateway that exposes REST on top of it.

Why does a test that checks only the HTTP status of a gRPC call prove almost nothing?

Answer

The server answers HTTP 200 whatever the result, and the real status arrives in the trailers as grpc-status. Such a test stays green on NOT_FOUND and on INTERNAL alike.

In an interview. Junior: gRPC is method calls by a .proto schema: binary Protobuf over HTTP/2, with streaming. For checks I use grpcurl or Postman with the schema. Middle/Senior: I explain the choice: internal services and low latency versus the simplicity and openness of REST. For QA it means automated tests on a generated client, checking grpc-status instead of an HTTP code, a linter and a schema compatibility check in CI, and separate gateway tests if there is one.

Protobuf: schema compatibility rules you must not break

In Protobuf a field is recognised by its number, not its name, so the number is part of the contract: it is never changed or reused. A new field gets a new number and a removed one is closed with reserved. Otherwise old and new clients read the same bytes differently, often with no error. Compatibility is checked automatically, for example with buf breaking in CI.

API · gRPC

A field was removed from the .proto, and a month later its number was given to a new one. What breaks?

A service release goes through, the tests are green, and in production some clients suddenly see a discount of 30 where there never was one. No errors in the logs. The reason is that two messages of different versions are compatible at the byte level but mean different things. The lesson explains why a field number is part of the contract in Protobuf, which changes are safe and how to check them automatically.

How it works and why it is designed so

In a binary message a field is recognised by its number and encoding type, not by its name: the name is absent from the bytes altogether, which is what keeps the format compact. So clients and servers of different versions that work at the same time rely on numbers alone. Compatibility has to hold both ways: backward (new servers read old messages) and forward (old ones read new). Modern implementations keep unknown fields and pass them on instead of dropping them.

Changes in a .proto: safe and not

Bad

Breaks compatibility

Change a field number or give a removed field's number to a new one. Change a type incompatibly. Remove a field without reserved.

Good

Safe

A new field with a new number. A new enum value, a new method or service. Removed numbers and names closed with reserved.

Figure 1. A field is recognised by its number, so the number is part of the contract.

Worked example: a number given away a second time

Before: field 3 meant a discount percentage. It was removed without closing the number:

// v1
message Cart {
  string id = 1;
  int32 discount_percent = 3;
}

// v2: the field is gone, but the number 3 is free
message Cart {
  string id = 1;
}

A month later a new field was added to the same message, taking the "free" number:

// v3
message Cart {
  string id = 1;
  int32 max_items = 3;
}

An old client that has not updated yet sends discount_percent = 30 under number 3 with the same encoding type. The new server reads it as max_items = 30, and in the other direction the old client shows the max_items it gets from the new server as a 30% discount. There is no error: the type matches, the bytes are valid. Such a mismatch shows up only in behaviour. The fix has two steps: never reuse a number, and close the removed field with reserved so the compiler refuses to let anyone take it:

message Cart {
  reserved 3;
  reserved "discount_percent";
  string id = 1;
  int32 max_items = 4;
}

An automatic check makes the mistake impossible: in CI buf breaking --against '.git#branch=main' compares the schema of a PR with the main branch and goes red on a reused number or a type change.

What else is worth knowing

  • Safe changes: a new field with a new number, a new enum value, a new method or service. Old clients ignore the new field, and new ones get the default from old servers.
  • Renaming a field. Nothing changes in the binary format, but the JSON representation and the source code of clients break, as do enum value names in JSON. This is checked separately.
  • Changing a type. Some integer types (int32, uint32, int64, bool) are mutually compatible but with truncation of values; string to int32 is not compatible.
  • Default values. In proto3 a scalar field with a zero value is not transmitted, and the receiver cannot tell "not set" from 0. For the difference between "discount 0%" and "no discount given" there is optional (a presence flag). The documentation considers wrappers such as Int32Value outdated for new fields.
  • Enum. The first value has to be zero and is usually named *_UNSPECIFIED: it becomes the default.
  • Numbers 1 to 15 are encoded with a one-byte tag, so they are kept for the most frequent fields.

Common mistakes

  • Removing a field without reserved: the number is "freed" and sooner or later gets taken again.
  • Changing a type to a "similar" one without checking: values are silently truncated.
  • Testing compatibility only on a new client with a new server: the errors show on an old client with a new server and the other way round.

Check yourself

Is it safe to rename the field email to contact_email without changing the number?

Answer

For the binary format yes, because the name is absent from the bytes. But the JSON representation (the key changed) and the source code of clients that call the generated methods break, so a rename needs separate coordination.

The "new client, new server" test is green, the incident happened on an old client. Which two scenarios are missing?

Answer

An old client with a fresh server (backward) and a new client with an old server (forward): they involve unknown fields, default values and new enum values.

In an interview. Junior: In Protobuf a field is recognised by its number, so it must not be changed or reused. New fields are added with new numbers. Middle/Senior: I close removed numbers and names with reserved and check compatibility automatically: buf breaking in CI and tests of an old client against a new server. Separately I remember the JSON representation, integer truncation and the difference between "not set" and zero via optional.

Call types, status codes, deadlines and metadata

The result of a gRPC call lives in grpc-status in the trailers, not in the HTTP code, because the server usually answers 200 whatever the outcome. The status follows the messages, since a stream may break midway. There are four call types: unary, server, client and bidirectional streaming. There is no deadline by default, so it is set explicitly, and retries are enabled only for idempotent methods.

API · gRPC

gRPC answered HTTP 200, yet the call still failed. Where do you look for the real result?

An automated test for a gRPC service is green: the response status is 200. A week later it turns out the method returned INTERNAL on every other request. The test looked in the wrong place. The lesson shows where the result lives in gRPC, what call types exist, how deadlines, retries and metadata work and what to check.

The four call types

HTTP/2 allows many streams in one connection, so gRPC has four RPC types: unary (one request, one response, the closest to REST), server streaming (an event feed, large selections), client streaming (a file upload, a batch of metrics) and bidirectional streaming (chat, interactive sessions).

Four call types

Unary1 request, 1 response Server streaming1 request, a stream of responses Client streaminga stream of requests, 1 response Bidirectionalboth sides send streams
Figure 1. Requests on the left, responses on the right: the only difference is how many messages go each way.

Where the result lives: statuses and trailers

A gRPC server answers with HTTP status 200 whatever the result: another code usually arrives only from a proxy or with a wrong content-type. The call status is appended by the server at the end, in the trailers, as grpc-status (a number) and grpc-message. It is done so because a response stream can break midway: the status cannot be known before the stream ends, so it is sent after the messages.

The structure of a gRPC response

HEADERS: HTTP 200content-type: application/grpcDATA: messageszero, one or many (a stream)TRAILERS: grpc-statusthe real result and grpc-message
Figure 2. The HTTP status stays 200, the result is read from the trailers.

The same call for a missing order looks roughly like this on the wire:

# schematic, not a verbatim output
HTTP/2 200
content-type: application/grpc

(the response body is empty)

grpc-status: 5
grpc-message: order 42 not found

The main codes and their closest HTTP counterparts:

CodeWhenHTTP
OK (0)success200
INVALID_ARGUMENT (3)the request is invalid by content400
DEADLINE_EXCEEDED (4)the deadline ran out504
NOT_FOUND (5)no such resource404
ALREADY_EXISTS (6)the resource already exists409
PERMISSION_DENIED (7)authenticated, not allowed403
RESOURCE_EXHAUSTED (8)limits, quotas, a too large message429
FAILED_PRECONDITION (9)the system state forbids the operation400
UNIMPLEMENTED (12)the method is not implemented501
INTERNAL (13)a server error500
UNAVAILABLE (14)temporarily unavailable, may be retried503
UNAUTHENTICATED (16)no valid credentials401

Error details (for example, which fields are invalid) are passed in a google.rpc.Status structure with typed details (BadRequest, ErrorInfo) in the grpc-status-details-bin trailer.

Metadata, deadlines, retries, interceptors

  • Metadata is the analogue of HTTP headers: key-value pairs at the start (headers) and at the end of a call (trailers). Keys are lowercase, binary ones have the -bin suffix, the grpc- prefix is reserved. Metadata carries the token (authorization: Bearer …), a trace id, the language.
  • A deadline is the time until which the client is ready to wait; on the wire it goes as grpc-timeout. By default there is no deadline, so a call can hang forever: production clients always set one. The deadline should propagate further down the chain of services, and after it expires the server should stop working.
  • Retries are set in the service config (retryPolicy: the number of attempts, backoff, the list of statuses in retryableStatusCodes, usually UNAVAILABLE). Only idempotent calls are worth retrying.
  • Interceptors (middleware) wrap calls on the client and the server: logging, authorisation, metrics, tracing.

Worked example: a test that looks in the right place

The test reads the code from the client's error, not the HTTP status, and sets the deadline explicitly:

// a 2 s deadline; expect NOT_FOUND for a missing id
const deadline = new Date(Date.now() + 2000);
const err = await new Promise<grpc.ServiceError | null>((resolve) =>
  client.getOrder({ id: 'missing' }, meta, { deadline }, (e) => resolve(e)),
);
expect(err?.code).toBe(grpc.status.NOT_FOUND);

Without an explicit deadline, a test of a slow dependency hangs until the framework timeout and never shows DEADLINE_EXCEEDED.

Limits. The HTTP equivalents in the table are a recommendation from google.rpc.Code, not a protocol rule: on a direct call the HTTP status stays 200, and a gateway or proxy may map codes its own way, so gateway tests check its actual codes. A stream's status arrives only at the end, so a test must read the stream to completion, or it will miss an error after the fifth message.

Common mistakes

  • Checking HTTP 200 instead of grpc-status: errors go unnoticed.
  • Not setting a deadline: the call hangs and CI keeps the agent busy until the overall timeout.
  • Enabling retries on non-idempotent methods: a repeat creates a duplicate.
  • Mixing up PERMISSION_DENIED and UNAUTHENTICATED: like 403 and 401, they are different access errors.

Check yourself

A stream of ten messages broke on the fifth, and the client received 200. Where do you see the error?

Answer

In the trailers: grpc-status comes after the messages, while HTTP 200 was already sent in the headers. The client library reports it as a stream error.

Why is retrying by default safe only for UNAVAILABLE and not INTERNAL?

Answer

UNAVAILABLE means the request most likely did not reach the server logic, so a retry is usually safe for an idempotent method. INTERNAL says the server logic already ran and failed, so a retry may repeat a partial side effect.

In an interview. Junior: gRPC has four call types. I read the result in grpc-status, not in the HTTP code, because the server returns 200. Middle/Senior: I explain that the status travels in the trailers because a stream can break midway. In tests I set the deadline explicitly, check INVALID_ARGUMENT with details, DEADLINE_EXCEEDED and that the server stops working after cancellation. I enable retries only for idempotent methods and UNAVAILABLE.

How a QA engineer tests a gRPC service

A gRPC service is tested with a generated client, while grpcurl or Postman stay for manual exploration. An automated test compares the status code with the expected one explicitly instead of merely checking that the call threw no exception. Validation, error codes, deadlines, streams, the message size limit and version compatibility are checked. CI runs buf lint and buf breaking, and the gateway and reflection in production are checked separately.

API · gRPC

Postman, grpcurl or code: what do you use to test a gRPC service, and what exactly do you check?

A service has just got a gRPC interface, while the team only has REST skills. The first thing you want to do is open Postman and send a request. That is fine for exploring, but automated tests that catch regressions are built differently. The lesson divides the tools by purpose and gives a list of checks, and shows by example what a test looks like that catches an error and not just a 200.

The tools and why these

  • grpcurl is "curl for gRPC". If server reflection is on, it takes the schema from there; otherwise pass -proto and -import-path. Metadata: -H.
  • Postman / Insomnia: gRPC requests with a .proto import or through reflection, handy for manual exploration and demos.
  • A generated client in the test framework. For TypeScript: @grpc/grpc-js with @grpc/proto-loader or typed code from ts-proto, Buf/Connect. This is the main option for automated tests: types catch mismatches with the schema at compile time.
  • buf: buf lint and buf breaking in CI show whether a PR broke backward compatibility of the schema.
  • Load: ghz or k6 (the k6/net/grpc module).

Where each check lives

Schema in CIbuf lint and buf breakingTests on a generated clientstatuses, deadlines, streamsGateway and browser pathgrpc-web, Gateway, status mappingLoadghz or k6 (k6/net/grpc)
Figure 1. Cheap schema checks come first, the more expensive ones later.
# list services and describe a method (needs reflection)
grpcurl -plaintext localhost:50051 list
grpcurl -plaintext localhost:50051 describe shop.v1.OrderService

# a call with metadata
grpcurl -plaintext -H 'authorization: Bearer TOKEN' \
  -d '{"id": "42"}' localhost:50051 shop.v1.OrderService/GetOrder

Worked example: a test that catches an error

The weak version only checks that the call did not throw. The strong one explicitly compares the status code with the expected one for each negative case:

import * as grpc from '@grpc/grpc-js';

const call = (req: object, meta = new grpc.Metadata()) =>
  new Promise<grpc.ServiceError | null>((resolve) =>
    client.getOrder(req, meta, { deadline: Date.now() + 2000 }, (e) => resolve(e)),
  );

test('an empty id gives INVALID_ARGUMENT', async () => {
  const err = await call({ id: '' });
  expect(err?.code).toBe(grpc.status.INVALID_ARGUMENT);
});

test('no token gives UNAUTHENTICATED', async () => {
  const err = await call({ id: '42' });
  expect(err?.code).toBe(grpc.status.UNAUTHENTICATED);
});

Such a test fails if validation is broken and the server starts returning INTERNAL or UNKNOWN on an empty id. A test that expects "just a response without an error" does not notice.

What to check

  • Positive scenarios and the values of all response fields, including defaults and optional.
  • Validation: empty, oversized, invalid fields give INVALID_ARGUMENT with correct details, not INTERNAL or UNKNOWN.
  • Error codes: NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED versus UNAUTHENTICATED (a missing, expired or foreign token).
  • Deadlines: a slow dependency gives DEADLINE_EXCEEDED, the server does not keep working after cancellation.
  • Streaming: message order, stream completion, cancellation by the client, a break midway, an empty stream.
  • Large messages: the size limit (the receive default is usually 4 MB) gives RESOURCE_EXHAUSTED, not a server crash.
  • Compatibility: an old client with a fresh server and the other way round, unknown fields and enum values.
  • Idempotency and retries: a repeated call after UNAVAILABLE creates no duplicates.
  • Security: TLS/mTLS, authorisation at the method level, reflection turned off in production or put behind authentication.

Browser and gateways

Direct gRPC from a browser is unavailable, so grpc-web through a proxy (for example Envoy), the Connect protocol or gRPC-Gateway, which gives REST/JSON on top of the service, are used. Tests should run on the gateway too: it has its own mapping of statuses to HTTP codes and its own JSON serialisation, and a bug can live only in that layer.

Common mistakes

  • Leaving reflection on in production: anyone can see all methods and types.
  • Testing only the happy path: validation and error codes stay uncovered.
  • Ignoring the gateway: tests pass on gRPC while the browser client breaks on the status mapping.
  • Putting one call type into a load test: streaming and unary behave differently.

Check yourself

grpcurl returns "server does not support the reflection API". What do you do?

Answer

Reflection is off (normal for production). Pass the schema manually: -proto order.proto -import-path ./proto. For automated tests the schema comes from the repository anyway.

Which two tests reveal that validation was broken and the server returns INTERNAL on an empty id?

Answer

A negative test with an empty id that expects exactly INVALID_ARGUMENT, and a test of the error details (BadRequest with the field name). A "no exception" test catches nothing.

In an interview. Junior: I check manually through grpcurl or Postman with the schema. I check field values and error codes. Middle/Senior: I write automated tests on a generated client and compare statuses explicitly, set deadlines, and cover streams, message limits and version compatibility. CI runs buf lint and buf breaking, I test the gateway separately and check that reflection is not open in production.

Mocking and virtualising gRPC dependencies in tests

A gRPC dependency in a test is replaced at one of three levels: an in-process fake, a stub driven by .proto, or a client mock. Only a server-level replacement keeps real deadlines, statuses and metadata. To keep the stand-in from drifting away from the provider, use a shared .proto, buf breaking in CI and a contract check against the real service.

An order service calls a gRPC pricing service. In the consumer's tests the real pricing service is unavailable, yet you need to check what happens when it answers UNAVAILABLE, does not fit the deadline, or breaks a stream halfway. A stand-in is needed, but where you put it decides what the test can notice at all.

Mechanism: three levels of replacement.

  • A fake service in the same process. An implementation of the service (a generated base class) is started as a real gRPC server and the client reaches it through a channel. In grpc-java that is InProcessServerBuilder and InProcessChannelBuilder: the call goes through the gRPC layer (serialisation, statuses, deadlines, metadata) but without a network or a port. Fast and deterministic;
  • A separate stub server driven by the schema. WireMock with the gRPC extension reads descriptors generated by protoc from your .proto (they go into the grpc directory of the WireMock root), converts messages to JSON, so the usual JSON matchers work, and responses can be templated. It needs WireMock 3.2.0 or newer. It suits consumers in different languages and environments where the stub is started as a container;
  • A mock of the generated client. In the consumer's code the client interface itself is replaced with a mocking library. The fastest, but all of gRPC is bypassed: the test no longer sees statuses, deadlines or metadata.

Why it works this way. Replacing at the client level checks only the consumer's own logic. Replacing at the server level keeps the real client in the test, and with it the real deadlines, retries and interceptors. So for "the dependency is down" scenarios you pick the first two levels and keep the client mock for tests of pure business logic.

Example: an in-process fake.

@Rule public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();

@Test
public void usesCachedPriceWhenPricingIsDown() throws Exception {
  String name = InProcessServerBuilder.generateName();
  grpcCleanup.register(InProcessServerBuilder.forName(name).directExecutor()
      .addService(new PricingGrpc.PricingImplBase() {
        @Override
        public void getPrice(PriceRequest req, StreamObserver<PriceReply> out) {
          out.onError(Status.UNAVAILABLE.withDescription("pricing is down").asRuntimeException());
        }
      }).build().start());
  ManagedChannel channel = grpcCleanup.register(
      InProcessChannelBuilder.forName(name).directExecutor().build());

  OrderService service = new OrderService(PricingGrpc.newBlockingStub(channel));
  assertThat(service.quote("sku-1").source()).isEqualTo("cached");
}

GrpcCleanupRule closes the channel and the server at the end of the test, and generateName() gives each test a unique server name. directExecutor() makes execution more deterministic.

What to check with a stand-in.

  • Error statuses. The fake returns UNAVAILABLE, NOT_FOUND, RESOURCE_EXHAUSTED, and the consumer reacts as designed: a retry, a fallback answer, a clear error for the user;
  • Deadline. The fake answers with a delay longer than the client's deadline: the consumer must get DEADLINE_EXCEEDED and not hang. A client mock will not show this;
  • Streams. A break after a few messages, an empty stream, a slow stream;
  • Metadata. An interceptor in the fake checks that the client sent a token and a correlation id;
  • Call count. A counter in the fake shows how many times the client repeated the call after an error.

Limits: a stand-in is only an assumption. A fake and a stub say what you put into them, so they drift from the real provider the same way mocks in unit tests do. Three safeguards keep them honest. First: one source of .proto for both sides, not a copy in the consumer's repository. Second: buf breaking in the provider's CI catches incompatible schema changes. Third: semantics (which statuses the service really returns, which fields it fills) is checked by a contract test or a small set of calls against the real service. For gRPC contracts Pact has a plugin framework that accepts new transports, gRPC among them: check the Pact plugin directory for whether a plugin exists for your language.

Common mistakes.

  • A client mock in every test: everything is green until a missing deadline brings production down;
  • A stand-in that returns only success: the consumer's error branches are never executed;
  • A private copy of the .proto that fell behind the provider: the stand-in answers with a schema that no longer exists;
  • The channel and the server are not closed: tests affect each other and threads leak.

Check yourself

A consumer test with a mock of the generated client is green, yet in production the call to the pricing service hangs with no answer. What do the tests lack?

Answer

A client mock bypasses the gRPC layer, so the deadline never fires in the test. You need a fake or a stub at the server level that answers later than the deadline, and a check that the consumer gets DEADLINE_EXCEEDED instead of waiting forever.

A stub returns a field that the provider's new version of the .proto no longer has, and the consumer tests are green. How do you catch this?

Answer

The stand-in knows nothing about the schema change. What helps is a shared .proto source, buf breaking in the provider's CI, and a contract or smoke test against the real service that compares the real response with what the stand-in assumes.

In an interview. Junior: a gRPC dependency in a test is replaced with a stand-in to check how the service behaves when it returns an error or answers slowly. Senior: I choose the level of replacement by what the test must see: for deadlines, statuses and metadata an in-process fake or a schema-driven stub, not a client mock; and so that the stand-in does not lie, I keep a shared .proto, buf breaking and a contract check against the provider.