{"id":21279027,"url":"https://github.com/lostatc/xpct","last_synced_at":"2025-07-11T08:33:29.750Z","repository":{"id":65116155,"uuid":"531908550","full_name":"lostatc/xpct","owner":"lostatc","description":"An extensible test assertion library for Rust","archived":false,"fork":false,"pushed_at":"2023-08-12T15:35:59.000Z","size":602,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-18T19:26:32.908Z","etag":null,"topics":["assertions","rust","testing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostatc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-02T12:02:50.000Z","updated_at":"2024-05-25T10:06:27.000Z","dependencies_parsed_at":"2023-02-10T19:16:00.444Z","dependency_job_id":null,"html_url":"https://github.com/lostatc/xpct","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostatc%2Fxpct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostatc%2Fxpct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostatc%2Fxpct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostatc%2Fxpct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostatc","download_url":"https://codeload.github.com/lostatc/xpct/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225708349,"owners_count":17511653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","rust","testing"],"created_at":"2024-11-21T10:18:23.130Z","updated_at":"2024-11-21T10:18:23.790Z","avatar_url":"https://github.com/lostatc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Tests Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/lostatc/xpct/test.yaml?branch=main\u0026label=Tests\u0026style=for-the-badge\u0026logo=github)](https://github.com/lostatc/xpct/actions/workflows/test.yaml)\n[![Crates.io](https://img.shields.io/crates/v/xpct?logo=rust\u0026style=for-the-badge)](https://crates.io/crates/xpct)\n[![docs.rs](https://img.shields.io/docsrs/xpct?logo=docs.rs\u0026style=for-the-badge)](https://docs.rs/xpct)\n\n# xpct\n\nxpct is an extensible test assertion library for Rust. It's designed to be\nergonomic, batteries-included, and test framework agnostic.\n\nWant to get started? [Check out the\ntutorial](https://docs.rs/xpct/latest/xpct/docs/tutorial/index.html).\n\n## About\n\nxpct is extensible. In addition to allowing you to write custom matchers, it\nseparates the logic of matchers from how they format their output, meaning you\ncan:\n\n1. Hook into existing formatters to write custom matchers with pretty output\n   without having to worry about formatting.\n2. Customize the formatting of existing matchers without having to reimplement\n   their logic.\n\nThis crate aims to provide many useful matchers out of the box. Check out the\nfull [list of provided\nmatchers](https://docs.rs/xpct/latest/xpct/docs/matcher_list/index.html).\n\n## Docs\n\n- [API Docs](https://docs.rs/xpct/latest/xpct/index.html)\n- [User Docs](https://docs.rs/xpct/latest/xpct/docs/index.html)\n  - [Tutorial](https://docs.rs/xpct/latest/xpct/docs/tutorial/index.html)\n  - [Provided Matchers](https://docs.rs/xpct/latest/xpct/docs/matcher_list/index.html)\n  - [Cargo Features](https://docs.rs/xpct/latest/xpct/docs/cargo_features/index.html)\n  - [Writing Custom Matchers](https://docs.rs/xpct/latest/xpct/docs/writing_matchers/index.html)\n  - [Writing Custom Formatters](https://docs.rs/xpct/latest/xpct/docs/writing_formatters/index.html)\n\n## Examples\n\nA simple equality assertion, like `assert_eq`:\n\n```rust,should_panic\nuse xpct::{expect, equal};\n\nexpect!(\"disco\").to(equal(\"Disco\"));\n```\n\n\u003cimg src=\"https://media.githubusercontent.com/media/lostatc/xpct/main/examples/equality.png\" width=\"400\" alt=\"stderr from failed assertion\" /\u003e\n\n[*Image transcript*](https://raw.githubusercontent.com/lostatc/xpct/main/examples/equality.txt)\n\nUnwrapping a `Some` value to make an assertion on the wrapped value:\n\n```rust,should_panic\nuse xpct::{be_gt, be_some, expect};\n\nexpect!(Some(41))\n    .to(be_some())\n    .to(be_gt(57));\n```\n\n\u003cimg src=\"https://media.githubusercontent.com/media/lostatc/xpct/main/examples/chaining.png\" width=\"400\" alt=\"stderr from failed assertion\" /\u003e\n\n[*Image transcript*](https://raw.githubusercontent.com/lostatc/xpct/main/examples/chaining.txt)\n\nMaking assertions about individual fields of a struct:\n\n```rust,should_panic\nuse xpct::{be_empty, be_in, be_true, expect, fields, have_prefix, match_fields, not, why};\n\nstruct Player {\n    id: String,\n    name: String,\n    level: u32,\n    is_superstar: bool,\n}\n\nlet player = Player {\n    id: String::from(\"REV12-62-05-JAM41\"),\n    name: String::from(\"\"),\n    level: 21,\n    is_superstar: false,\n};\n\nexpect!(player).to(match_fields(fields!(Player {\n    id: have_prefix(\"REV\"),\n    name: not(be_empty()),\n    level: be_in(1..=20),\n    is_superstar: why(be_true(), \"only superstars allowed\"),\n})));\n```\n\n\u003cimg src=\"https://media.githubusercontent.com/media/lostatc/xpct/main/examples/fields.png\" width=\"600\" alt=\"stderr from failed assertion\" /\u003e\n\n[*Image transcript*](https://raw.githubusercontent.com/lostatc/xpct/main/examples/fields.txt)\n\nMaking assertions about elements in a collection:\n\n```rust,should_panic\nuse xpct::{be_in, contain_substr, equal, expect, have_len, match_elements};\n\nlet items = vec![\"apple\", \"pear\", \"banana\"];\n\nexpect!(items)\n    .to(have_len(3))\n    .to(match_elements([\n        contain_substr(\"ana\"),\n        equal(\"pear\"),\n        be_in([\"mango\", \"orange\"]),\n    ]));\n```\n\n\u003cimg src=\"https://media.githubusercontent.com/media/lostatc/xpct/main/examples/collections.png\" width=\"500\" alt=\"stderr from failed assertion\" /\u003e\n\n[*Image transcript*](https://raw.githubusercontent.com/lostatc/xpct/main/examples/collections.txt)\n\nShowing rich diffs of data structures:\n\n```rust,should_panic\nuse xpct::{eq_diff, expect};\n\nexpect!([\"apple\", \"banana\"]).to(eq_diff([\"banana\", \"orage\"]));\n```\n\n\u003cimg src=\"https://media.githubusercontent.com/media/lostatc/xpct/main/examples/diff.png\" width=\"500\" alt=\"stderr from failed assertion\" /\u003e\n\n[*Image transcript*](https://raw.githubusercontent.com/lostatc/xpct/main/examples/diff.txt)\n\n## MSRV Policy\n\nThe last two stable Rust releases are supported. Older releases may be supported\nas well.\n\nThe MSRV will only be increased when necessary—not every time there is a new\nRust release. An increase in the MSRV will be accompanied by a minor semver bump\nif \u003e=1.0.0 or a patch semver bump if \u003c1.0.0.\n\n## Semver Policy\n\nPrior to version 1.0.0, breaking changes will be accompanied by a minor version\nbump, and new features and bug fixes will be accompanied by a patch version\nbump.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostatc%2Fxpct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostatc%2Fxpct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostatc%2Fxpct/lists"}