{"id":15032160,"url":"https://github.com/foresterre/sif","last_synced_at":"2026-02-25T13:07:41.734Z","repository":{"id":57667325,"uuid":"277913517","full_name":"foresterre/sif","owner":"foresterre","description":"🐺 Yet another parameterized testing library for Rust","archived":false,"fork":false,"pushed_at":"2024-12-10T22:33:38.000Z","size":45,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T05:58:20.203Z","etag":null,"topics":["case","hacktoberfest","macro","parameterized","parameterized-test","rust","test","testing","unit","unit-test","unit-testing"],"latest_commit_sha":null,"homepage":"","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/foresterre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2020-07-07T20:17:57.000Z","updated_at":"2024-12-10T22:33:38.000Z","dependencies_parsed_at":"2024-09-24T20:17:36.054Z","dependency_job_id":null,"html_url":"https://github.com/foresterre/sif","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"68fcfc14453dc8a265131c5b8519b4b63ef6c751"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fsif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fsif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fsif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresterre%2Fsif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foresterre","download_url":"https://codeload.github.com/foresterre/sif/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248547163,"owners_count":21122460,"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":["case","hacktoberfest","macro","parameterized","parameterized-test","rust","test","testing","unit","unit-test","unit-testing"],"created_at":"2024-09-24T20:17:34.727Z","updated_at":"2025-10-29T02:42:04.495Z","avatar_url":"https://github.com/foresterre.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sif\n\nSif provides a procedural macro which allows you to define a test to be run with multiple arguments.\nTest cases are defined using the 'parameterized' attribute instead of the 'test' attribute.\nThis crate was inspired by the JUnit `@ParameterizedTest` annotation and builds on the development experience of the\n[parameterized](https://github.com/foresterre/parameterized) crate.\n\n### Examples:\n\nAside from the two examples below you can find additional examples in the \u003ca href=\"sif_demo\"\u003esif_demo\u003c/a\u003e crate in\nthis repository and in the \u003ca href=\"sif_macro/tests\"\u003etests\u003c/a\u003e folder.\n\n\u003cbr\u003e\n\n**Example: NPCs**\n\n```rust\n#[cfg(test)] #[macro_use] extern crate sif;\n\nenum NPC {\n    Andre,\n    Lautrec,\n    Siegmeyer,\n    Solaire,\n}\n\ntrait Home {\n    fn reigns_from(\u0026self) -\u003e \u0026str;\n}\n\nimpl Home for NPC {\n    fn reigns_from(\u0026self) -\u003e \u0026str {\n        match self {\n            NPC::Solaire | NPC::Andre =\u003e \"Astora\",\n            NPC::Lautrec =\u003e \"Carim\",\n            NPC::Siegmeyer =\u003e \"Catarina\",\n        }\n    }\n}\n\n#[parameterized]\n#[case(NPC::Andre, \"Astora\")]\n#[case(NPC::Lautrec, \"Carim\")]\n#[case(NPC::Siegmeyer, \"Catarina\")]\n#[case(NPC::Solaire, \"Astora\")]\nfn npc_reigns_from_test(npc: NPC, place: \u0026str) {\n    assert_eq!(npc.reigns_from(), place)\n}\n\n```\n\n\u003cbr\u003e\n\n### Importing Sif\nWith Rust 2018, there are two primary ways to import an attribute macro.\n\nThe first is by importing the macro into the local scope like a regular import, for example: `use sif::parameterized;`.\nThis method also makes it easy to alias the macro's attribute to some other identifier, e.g.  `use sif::parameterized as pm;`.\n\nThe second is by using `extern crate` in combination with the `macro_use` attribute (for example: `#[cfg(test)] #[macro_use] extern crate sif;`).\nThis second option has an advantage if you use the macro a lot in your crate, since you only have to import it once at the root of the crate.\n\n### Running tests with IDE's\n\n#### IntelliJ IDEA (+ intellij-rust)\n\nIntelliJ IDEA recognises test cases and provides context menus which allow you to run tests within a certain scope\n(such as a module or a single test case), for example by clicking the ▶ icon in the gutter next to\nthe start of a block containing a `#[test]`. Unfortunately, as attribute macros are currently not expanded,\nthe IDE will not recognise the test cases generated by the `sif::parameterized` macro. Since I find this way of running tests\nrather useful, I opted to implement a simple workaround by providing a small declarative macro which expands to an empty test case.\n\n\u003c!-- I've also attempted various other solutions, which will be documented in #ISSUENR. --\u003e\n\n```rust\n#[cfg(test)] #[macro_use] extern crate sif;\n\nfn squared(input: i8) -\u003e i8 {\n  input * input  \n}\n\n#[cfg(test)]\n/*▶*/mod tests {\n    use super::*;\n\n/*▶*/mod squared_tests { // \u003c--\n        use super::*;\n\n        // this macro generates an empty test case which will mark the module as containing tests.\n        ide!(); // \u003c--\n    \n        #[parameterized]\n        #[case(-2, 4)]\n        #[case(-1, 1)]\n        #[case(0, 0)]\n        #[case(1, 4)]\n        fn test_squared(input: i8, output: i8) {\n            assert_eq(squared(input), output);\n        }\n    }\n}\n\n```\n### License\n\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\n\u003cbr\u003e\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesterre%2Fsif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforesterre%2Fsif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesterre%2Fsif/lists"}