百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

Rumpel

> 编程语言
开源

为您的 JSON API 提供简单、专注且自动化的消费者驱动合约测试

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

为您的 JSON API 提供简单、专注且自动化的消费者驱动合约测试

Rumpel

Simple, opinionated and automated consumer-driven contract testing for your JSON API's

Install

copy+paste one of the following commands in your terminal.

Linux x64

bash
curl -Lo rumpel https://github.com/hellgrenj/Rumpel/releases/download/v0.4.2/rumpel-linux-x64 && \
sudo install rumpel /usr/local/bin/

macOS arm64

bash
curl -Lo rumpel https://github.com/hellgrenj/Rumpel/releases/download/v0.4.2/rumpel-macos-arm64 && \
sudo install rumpel /usr/local/bin/

win x64
download the latest exe, rename it rumpel.exe and put it in your PATH.

Docker:
https://hub.docker.com/r/hellgrenj/rumpel.

Helm (Experimental!):
https://github.com/hellgrenj/charts/tree/main/rumpel-mock#install-and-test
(only for mocking services right now..)

Use

Record a consumer-driven contract against a known and reproducible state of the API and system under test (SUT). Use the created contract to verify that the API still works for this specific consumer when making changes to the API. Make sure you verify against the same SUT-state as you recorded against.

You can also use the contract on the consumer side to mock the provider in local development. In this mode Rumpel will validate the consumer requests, making sure that the consumer upholds its end of the contract.

tldr

rumpel --record-contract --target-api=http://localhost:8080 --contract-name=msA-msB
rumpel --verify-contract --contract-path=./contracts/msA-msB.rumpel.contract.json
rumpel --mock-provider --contract-path=./contracts/msA-msB.rumpel.contract.json

examples

Demo application: artlab
a demo of Docker, Kubernetes and Skaffold where Rumpel is used to record a contract and mock a dependency.

Rumpel can do 3 things:

  1. Record a contract (i.e turning your implicit contract into an explicit one).
    rumpel --record-contract --target-api=http://localhost:8080 --contract-name=msA-msB

Rumpel listens on port 8181 or the number set in the environment variable RUMPEL_PORT
screenshot

  1. Verify a contract (i.e making sure the API still works for a specific consumer)
    rumpel --verify-contract --contract-path=./contracts/msA-msB.rumpel.contract.json

Contract verification supports bearer tokens and you can skip certain assertions with ignore-flags.
Run the --help command for more information.
This should be a part of the Providers CI/CD pipeline, see ./tests/integration for an example on how to do this with docker-compose.
screenshots

Customizations
You can customize the verification per transaction by manually adding Customizations in the contract. In the example below a Customization is added that instructs Rumpel to ignore the object property name. A Customization has 3 properties: The name of the target Object Property, The name of the Action and at what Depth in the JSON the property is found. (is it a first level property or a property in a nested object..)

Available Customizations

  • CompareObjectPropertyValues (have Rumpel assert that the value is the same as the recorded value)
  • IgnoreObjectProperty (ignores one specific property in the object, i.e allow it to be missing or changed)
  1. Mock a provider/API
    rumpel --mock-provider --contract-path=./contracts/msA-msB.rumpel.contract.json

This can be used in local dev environments to mock dependencies, see ./tests/integration for an example of how to do this with docker-compose or the repository artlab for an example of how to do this with Skaffold. You can also mock services in different k8s-clusters with this (experimental) helm chart: https://github.com/hellgrenj/charts/tree/main/rumpel-mock#install-and-test
Rumpel listens on port 8181 or the number set in the environment variable RUMPEL_PORT.
In this mode Rumpel validates the requests sent by the consumer.
screenshot

Simulated conditions
You can simulate conditions per transaction when mocking a provider by manually adding SimulatedConditions in the contract. Every simulated condition has a Type and a Value, see the screenshot below for an example. You can add one or several simulated conditions, in the example below we are adding 3 different conditions.

Available Types of Simulated conditions and the expected Values

  • Sometimes500 (Rumpel will have this request fail with status code 500 according to the percentage set as the Value. In the example (screenshot) above the request will fail approximately 35% of the time)
  • FixedDelay (Rumpel will add a delay to this request. The Value is the fixed delay in milliseconds)
  • RandomDelay (Rumpel will add a random delay between the min and max value provided in the Value property. The min and max values are expected to be provided with the following syntax: minMilliseconds-maxMilliseconds)

Rumpel has 5 commands:

--record-contract or the shorthand -r
--verify-contract or the shorthand -v
--mock-provider or the shorthand -m
--help or the shorthand -h
--version

Develop

You need the following installed on your dev machine:

  • dotnet 6.x
  • docker 20.10.x
  • docker-compose 1.29.x
  • deno 1.15.x

tests

There are both unit tests and integration tests. Check the ./tests folder.
Run unit tests in ./tests/unit with dotnet test
Run integration tests in ./tests/integration with deno run -A tests.ts
Run ALL tests in ./tests with deno run -A run_all_tests.ts

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言