All Projects → alexliesenfeld → Httpmock

alexliesenfeld / Httpmock

Licence: mit
HTTP mocking library for Rust.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Httpmock

zmock
zmock--http接口的mock平台
Stars: ✭ 98 (+28.95%)
Mutual labels:  mock, test, mock-server
Mockito
HTTP mocking for Rust!
Stars: ✭ 335 (+340.79%)
Mutual labels:  test, mock, test-framework
Smocker
Smocker is a simple and efficient HTTP mock server and proxy.
Stars: ✭ 465 (+511.84%)
Mutual labels:  test, mock, mock-server
Fakerest
Patch fetch/XMLHttpRequest to fake a REST API server in the browser, based on JSON data.
Stars: ✭ 350 (+360.53%)
Mutual labels:  test, mock
Mockman
Manage and start the mock servers on your local platform easily
Stars: ✭ 281 (+269.74%)
Mutual labels:  mock, mock-server
Mastermind
Man in the middle testing
Stars: ✭ 341 (+348.68%)
Mutual labels:  test, mock
bdd-for-c
A simple BDD library for the C language
Stars: ✭ 90 (+18.42%)
Mutual labels:  test, test-framework
Testfx
MSTest V2 framework and adapter
Stars: ✭ 391 (+414.47%)
Mutual labels:  test, test-framework
Mimic
Seamless client side mocking
Stars: ✭ 380 (+400%)
Mutual labels:  test, mock
Mocha
☕️ simple, flexible, fun javascript test framework for node.js & the browser
Stars: ✭ 20,986 (+27513.16%)
Mutual labels:  test, test-framework
Kakapo.js
🐦 Next generation mocking framework in Javascript
Stars: ✭ 535 (+603.95%)
Mutual labels:  mock, mock-server
Ohhttpstubs
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
Stars: ✭ 4,831 (+6256.58%)
Mutual labels:  mock, mock-server
Fxtest
接口自动化测试平台——python+flask版,支持http协议,java 版本开发完毕https://github.com/liwanlei/plan
Stars: ✭ 564 (+642.11%)
Mutual labels:  test, mock-server
mokker
The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0
Stars: ✭ 13 (-82.89%)
Mutual labels:  mock, mock-server
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (+43.42%)
Mutual labels:  mock, test
Shellspec
A full-featured BDD unit testing framework for bash, ksh, zsh, dash and all POSIX shells
Stars: ✭ 375 (+393.42%)
Mutual labels:  test, mock
stub-server
Stub server for REST APIs
Stars: ✭ 14 (-81.58%)
Mutual labels:  mock, test
jsxmock
使用 JSX 来定义 Mock Server
Stars: ✭ 31 (-59.21%)
Mutual labels:  mock, mock-server
Backbone Faux Server
A framework for mocking up server-side persistence / processing for Backbone.js
Stars: ✭ 55 (-27.63%)
Mutual labels:  test, mock
Wiremockui
Wiremock UI - Tool for creating mock servers, proxies servers and proxies servers with the option to save the data traffic from an existing API or Site.
Stars: ✭ 38 (-50%)
Mutual labels:  mock, mock-server

httpmock

HTTP mocking library for Rust.

Build Status codecov crates.io Rust License

Documentation · Crate · Report Bug · Request Feature · Changelog

Features

  • Simple, expressive, fluent API.
  • Many built-in helpers for easy request matching.
  • Parallel test execution.
  • Extensible request matching.
  • Fully asynchronous core with synchronous and asynchronous APIs.
  • Debugging support.
  • Network delay simulation.
  • Standalone mode with an accompanying Docker image.
  • Support for Regex matching, JSON, serde, cookies, and more.

Getting Started

Add httpmock to Cargo.toml:

[dev-dependencies]
httpmock = "0.5.7"

You can then use httpmock as follows:

use httpmock::MockServer;
use httpmock::Method::GET;

// Start a lightweight mock server.
let server = MockServer::start();

// Create a mock on the server.
let hello_mock = server.mock(|when, then| {
    when.method(GET)
        .path("/translate")
        .query_param("word", "hello");
    then.status(200)
        .header("Content-Type", "text/html; charset=UTF-8")
        .body("Привет");
});

// Send an HTTP request to the mock server. This simulates your code.
let response = isahc::get(server.url("/translate?word=hello")).unwrap();

// Ensure the specified mock was called exactly one time (or fail with a detailed error description).
hello_mock.assert();
// Ensure the mock server did respond as specified.
assert_eq!(response.status(), 200);

The above example will spin up a lightweight HTTP mock server and configure it to respond to all GET requests to path /translate with query parameter word=hello. The corresponding HTTP response will contain the text body Привет.

Usage

See the reference docs for detailed API documentation.

Examples

You can find examples in the httpmock test directory. The reference docs also contain a lot of examples. There is an online tutorial as well.

License

httpmock is free software: you can redistribute it and/or modify it under the terms of the MIT Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT Public License for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].