Skip to content

Conversation

@renovate
Copy link

@renovate renovate bot commented Dec 11, 2025

This PR contains the following updates:

Package Type Update Change
mockito dev-dependencies minor 0.130.32

Release Notes

lipanski/mockito (mockito)

v0.32.5

Compare Source

  • Implement and enable a new server pool and get rid of the deadpool dependency
  • Replace the mpsc mock/server communication with Arc (more reliable in this case)
  • Split sync & async paths more clearly

v0.32.4

Compare Source

  • Introduce Mock::with_body_from_request which allows setting the response body dynamically, based on the Request object
  • Small performance improvement: replace the state Mutex with an RwLock
  • Small fixes to the documentation (thanks @​konstin)

v0.32.3

Compare Source

  • Various fixes addressing hanging/flickering tests
  • Server::new and Server::new_async now return a ServerGuard object which dereferences to Server - this is only relevant if you need to assign a type to your server
  • The server pool has been disabled and will be brought back in a future release

v0.32.2

Compare Source

  • Prevent the Mock destructor from hanging in some cases
  • Updates to the docs, clarifying the usage of _async methods

v0.32.1

Compare Source

v0.32.0

Compare Source

This is a major re-write, introducing a bunch of long awaited features:

  • [Breaking] The minimum supported Rust version was bumped to 1.65.0

  • Tests can now run in parallel as long as you use the new mockito::Server API:

    let mut server = mockito::Server::new();
    let mock = server.mock("GET", "/").with_body("test").create();
    
    // Use one of these to configure your client
    let host = server.host_with_port();
    let url = server.url();
  • You can run multiple servers/hosts at the same time:

    let mut twitter = mockito::Server::new();
    let twitter_mock = server.mock("GET", "/api").with_body("tweet").create();
    let twitter_host = twitter.host_with_port();
    
    let mut github = mockito::Server::new();
    let github_mock = server.mock("GET", "/api").with_body("repo").create();
    let github_host = github.host_with_port();
  • Support for HTTP2

  • An async interface for all actions (though the sync interface is also available):

    let mut server = Server::new_async().await;
    let mock = s
        .mock("GET", "/hello")
        .with_body("world")
        .create_async()
        .await;
    
    mock.assert_async().await;
  • The backend has been rewritten to use Hyper

This version will be backwards compatible with the previous version, but deprecation warnings have been introduced and you are encouraged to migrate, since the old API still requires running tests sequentially. Migrating to the new API is quite straighforward:

Migrating to the new API

Legacy API:

let m = mockito::mock("GET", "/").with_body("hello").create();

// Use one of these to configure your client
let host = mockito:server_address();
let url = mockito::server_url();

New API:

let mut server = mockito::Server::new();
let m = sever.mock("GET", "/").with_body("hello").create();

// Use one of these to configure your client
let host = server.host_with_port();
let url = server.url();

Migrating to the async API

In order to write async tests, you'll need to use the _async methods:

  • Server::new_async
  • Mock::create_async
  • Mock::assert_async
  • Mock::matched_async
  • Server::reset_async

...otherwise your tests will not compile and you'll see this error: Cannot start a runtime from within a runtime.

When using tokio, prefer the single-threaded runtime over the multi-threaded one.

Example:

#[tokio::test]
async fn test_simple_route_mock_async() {
    let mut server = Server::new_async().await;
    let m1 = server.mock("GET", "/a").with_body("aaa").create_async().await;
    let m2 = server.mock("GET", "/b").with_body("bbb").create_async().await;

    let (m1, m2) = futures::join!(m1, m2);

    // You can use `Mock::assert_async` to verify that your mock was called
    // m1.assert_async().await;
    // m2.assert_async().await;
}

v0.31.1

Compare Source

  • Prevent tests from blocking endlessly when encountering HTTP parsing errors.

Thanks to @​chantra

v0.31.0

Compare Source

  • Replaced the unmaintained difference crate with the similar crate.

Thanks to @​ameliabradley

v0.30.0

Compare Source

  • Update the assert-json-diff dependency.

Thanks to @​davidpdrsn

v0.29.0

Compare Source

Thanks to @​kornelski and @​davidpdrsn

v0.28.0

Compare Source

  • Introduced the Matcher::Binary variant for matching binary content.

Thanks to @​torrefatto

v0.27.0

Compare Source

  • Added a Mock#matched() as a soft way of checking that a Mock, as opposed to the Mock#assert() method, which panics.

Thanks @​max-b

v0.26.0

Compare Source

  • [Breaking] Increased the minimum supported Rust version to 1.36.0.

v0.25.3

Compare Source

  • Fixed and issue where spaces encoded as + wouldn't be interpreted properly by Matcher::UrlEncoded.

Thanks to @​cakekindel

v0.25.2

Compare Source

  • Improve error messages and the String representation of mocks, especially when it comes to their AllOf and AnyOf parts.

Thanks to @​max-b

v0.25.1

Compare Source

  • When creating multiple mocks that match the same request, the last defined mock should be the one matched forever, once the all other mocks have reached their expected amount of hits. See #​99 and 96f3e30

v0.25.0

Compare Source

  • You can provide different mocks (and especially mock responses) for subsequent requests to the same endpoint. See #​99 and b0966f8
  • The 501 Mock Not Implemented response now comes with a content-length: 0 header, to prevent some clients from hanging.

Thanks to @​xneomac

v0.23.3

Compare Source

  • Fix compatibility with the assert-json-diff library (version 1.0.3)

v0.23.2

Compare Source

  • Fix a problem regarding the assert-json-diff library.

Thanks to @​vldm

v0.23.1

Compare Source

  • Set the connection: close header on all responses delivered by Mockito as this is the default behaviour at the moment.

v0.23.0

Compare Source

  • [Breaking] Increased the minimum supported Rust toolchain to 1.35.0.
  • Introduced the Mock#expect_at_least and Mock#expect_at_most functions to be used together with Mock#assert.
  • Bumped the percent-encoding dependency.
  • Introduced cargo fmt formatting as part of CI.

Thanks to @​kornelski @​xneomac @​thomasetter

v0.22.0

Compare Source

  • Applied the Rust 2018 edition.
  • Fixed an issue regarding usage of the AnyOf matcher for the path/query parts within a mock call.

Thanks to @​thomasetter

v0.21.0

Compare Source

  • Introduced a feature flag color (enabled by default), that controls whether the output is coloured and, more importantly, whether the colored crate is required.

Thanks to @​repi

v0.20.0

Compare Source

  • Introduced the Matcher::PartialJson and Matcher::PartialJsonString variants to match a JSON String partially (inclusion).

Thanks to @​matteosister

v0.19.0

Compare Source

  • Introduced the Mock#with_body_from_fn function, which allows generating the response body programmatically.

Thanks to @​kornelski

v0.18.0

Compare Source

  • [Breaking] The minimum supported Rust version was increased to 1.32, after upgrading the rand crate dependency to 0.7.0.
  • Introduced Matcher::AllOf, which can be used to check a set of matchers in conjunction. It works in a similar way to the existing Matcher::AnyOf.
  • Introduced Matcher::UrlEncoded to match key/value pairs in URL-encoded strings.
  • Introduced Mock#match_query to be able to match the URL query part distinctly from the path. The function supports all known matchers but works best with Matcher::UrlEncoded. The old behaviour of matching the query as part of the path argument in a mock call has been preserved, but using Mock#match_query has the effect of overriding that.

🎈 🎈 🎈

v0.17.1

Compare Source

  • Exclude CI & other unrelated files from packaging and turn the binary into an example.

Thanks to @​ignatenkobrain

v0.17.0

Compare Source

  • Support Transfer-Encoding: chunked.

Thanks to @​loyd

v0.16.0

Compare Source

  • Support HTTP/1.0 and working without Content-Length.
  • Allow overriding the Content-Length response header and skipping the response body entirely in the particular case of HEAD requests.

Thanks to @​loyd

v0.15.1

Compare Source

Thanks to @​saks

v0.15.0

Compare Source

  • [Breaking] The mock sever will get a dynamically assigned port, though it will try port 1234 first. You will need to change the way you set the server URL - from mockito::SERVER_URL or mockito::SERVER_ADDRESS to mockito::server_url() or mockito::server_address().

Thanks to @​kornelski

v0.14.1

Compare Source

  • Refactored the server checks - thanks to @​kornelski
  • Debug mode: use the log crate instead of the old custom logger - thanks to @​kornelski
  • Keep compatibility with older toolchains - thanks to @​lucab
  • Introduce clippy - thanks to @​macisamuele

v0.14.0

Compare Source

~~This is the release candidate for the 1.0.0 🎉 ~~

  • [Breaking] Fully deprecated Matcher::JSON, in favour of Matcher::Json.
  • Replace http-muncher with httparse. This fixed the issues regarding the failing Windows tests. See #​51 and #​41
  • Updated dependencies.

Thanks to @​sterlingjensen, @​otavio, @​galaxie and @​mikrostew


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant