1 of 11

Avoiding APIpocalypse; �API Resiliency Testing FTW!

Naresh Jain�naresh@xnsio.com

2 of 11

What is a Contract?

© 2024 All Rights Reserved

3 of 11

Evaluate 30.1 x 43.74 + 22 / 7

30.1 x 43.74

1316.574

22 / 7

3.142

1316.574 + 3.142

1319.716

4 of 11

Evaluate 30.1 x 43.74 + 22 / 7

Post /calculator {lhs: 30.1, rhs: 43.74, op: “multiply”}

200 {result: 1316.574}

Post /calculator {lhs: 22, rhs: 7, op: “divide”}

200 {result: 3.142}

Post /calculator {lhs: 1316.574, rhs: 3.142, op: “add”}

200 {result: 1319.716}

5 of 11

API Tests

Post /calculator {lhs: 30.1, rhs: 43.74, op: “multiply”}

200 {result: 1316.574}

Post /calculator {lhs: -30.1, rhs: 43.74, op: “multiply”}

200 {result: -1316.574}

Post /calculator {lhs: “abc”, rhs: 43.74, op: “multiply”}

400 Bad Request {reason: “Invalid lhs value”}

Post /calculator {lhs: 30.1, rhs: 43.74, op: “junk”}

400 Bad Request {reason: “Invalid operation”}

6 of 11

Open API Spec

7 of 11

Contract Tests

Post /calculator {lhs: number, rhs: number, op: “multiply”}

200 {result: number}

Post /calculator {lhs: -number, rhs: number, op: “multiply”}

200 {result: -number}

Post /calculator {lhs: string, rhs: number, op: “multiply”}

400 Bad Request {reason: string}

Post /calculator {lhs: number, rhs: number, op: “junk”}

400 Bad Request {reason: string}

Op: add

subtract

multiply

divide

8 of 11

Unit Tests

Contract Tests

Component

or

API Tests

Workflow

Tests

System

Tests

1%

70%

20%

6%

3%

Performance Tests

Security Tests

Exploratory Testing

% of Tests

Visual Tests

Instrumentation Tests

9 of 11

Demo Application Architecture

Request

Response

Request

Response

1

2

3

4

5

Message

Topic

Domain Service

App

BFF

Analytics Service

© 2024 All Rights Reserved

10 of 11

Live Demo

© 2024 All Rights Reserved

11 of 11

naresh@xnsio.com

@nashjain

Thank you!