{"id":16338891,"url":"https://github.com/vorner/minimal-fixtures","last_synced_at":"2025-06-13T10:37:46.184Z","repository":{"id":66117410,"uuid":"128255504","full_name":"vorner/minimal-fixtures","owner":"vorner","description":"Minimal test fixtures as proc-macro decorators (experimental)","archived":false,"fork":false,"pushed_at":"2018-04-14T18:22:25.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T04:08:46.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vorner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-05T19:39:00.000Z","updated_at":"2022-07-28T22:30:38.000Z","dependencies_parsed_at":"2023-02-20T17:31:01.191Z","dependency_job_id":null,"html_url":"https://github.com/vorner/minimal-fixtures","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vorner%2Fminimal-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vorner%2Fminimal-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vorner%2Fminimal-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vorner%2Fminimal-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vorner","download_url":"https://codeload.github.com/vorner/minimal-fixtures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239412471,"owners_count":19634016,"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":[],"created_at":"2024-10-10T23:53:01.271Z","updated_at":"2025-02-18T05:16:41.927Z","avatar_url":"https://github.com/vorner.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal testing fixtures for Rust\n\nThe built in testing framework of Rust is lightweight, one could even say that\nit is bare-bones. Oftentimes, some kind of fixtures ‒ *things* that are similar\nthrough many tests ‒ come handy, to avoid code duplication.\n\nThere's a poor-man's implementation of a fixture:\n\n```rust\nstruct Fixture {\n    // Whatever, some values go in here...\n    value: u32,\n}\n\nimpl Default for Fixture {\n    fn default() -\u003e Self {\n        // Any test setup (preparing a database, creating test files, etc) might\n        // go in here.\n        Self {\n            value: 42,\n        }\n    }\n}\n\nimpl Drop for Fixture {\n    fn drop(\u0026mut self) {\n        // Any test tear down (shutting down the database) might go in here.\n    }\n}\n\n#[test]\nfn perform_test() {\n    let fixture = Fixture::default();\n\n    assert_eq!(42, fixture.value);\n}\n```\n\nWhile this works, it's far from elegant. This crate allows using the fixture in\na bit more convenient way:\n\n```rust\n#[minimal_fixture] // Instead of #[test]\nfn perform_another_test(fixture: \u0026Fixture) {\n    assert_eq!(42, fixture.value);\n}\n```\n\nAs additional feature, it is possible to create a fixture that supplies multiple\nvalues (see the docs). The test is run with each such value.\n\nIt is possible to supply multiple fixtures, and the test is run with each\ncombination of the values they provide.\n\n## Status\n\nThis is still in an early experimental state. It is likely it won't work in many\ncases. Also, error handling is somewhat minimal and if it fails to compile, the\nerror messages aren't very helpful.\n\nIt exists mostly to answer two questions:\n* Is it actually useful?\n* If so, is a separate (proc-macro) crate the way to go, or would writing an RFC\n  and trying to include it into the in-built testing framework. There are some\n  features that don't seem possible with proc-macro only.\n\nFor these reasons (and because I'm not happy with the name), it is not yet\npublished on crates.io.\n\n## Nightly features\n\nFor now, proc-macro is a nightly only feature, so to use it, you need to enable\nit:\n\n```rust\n#![feature(proc_macro)]\nextern crate minimal_fixtures;\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms\nor conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvorner%2Fminimal-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvorner%2Fminimal-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvorner%2Fminimal-fixtures/lists"}