{"id":22862410,"url":"https://github.com/dylibso/xtp-test-rust","last_synced_at":"2026-02-02T21:18:20.554Z","repository":{"id":233335041,"uuid":"785357189","full_name":"dylibso/xtp-test-rust","owner":"dylibso","description":"A Rust test framework for xtp / Extism plugins.","archived":false,"fork":false,"pushed_at":"2024-05-22T22:59:10.000Z","size":20,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-06T17:49:54.395Z","etag":null,"topics":["extism","plugins","testing","unit-testing","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://extism.org/docs/concepts/testing/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dylibso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-04-11T18:16:55.000Z","updated_at":"2024-05-22T22:59:13.000Z","dependencies_parsed_at":"2024-04-15T21:28:46.517Z","dependency_job_id":"875d35dd-6f8e-4ea0-ae11-1395a7fc08b4","html_url":"https://github.com/dylibso/xtp-test-rust","commit_stats":null,"previous_names":["dylibso/xtp-test-rust"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dylibso/xtp-test-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fxtp-test-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fxtp-test-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fxtp-test-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fxtp-test-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dylibso","download_url":"https://codeload.github.com/dylibso/xtp-test-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fxtp-test-rust/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29020021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T18:51:31.335Z","status":"ssl_error","status_checked_at":"2026-02-02T18:49:20.777Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["extism","plugins","testing","unit-testing","wasm","webassembly"],"created_at":"2024-12-13T10:13:28.325Z","updated_at":"2026-02-02T21:18:20.540Z","avatar_url":"https://github.com/dylibso.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xtp-test\n\nA Rust test framework for [xtp](https://getxtp.com) /\n[Extism](https://extism.org) plugins.\n\n## Example\n\n```rust\nuse extism_pdk::*;\nuse xtp_test;\n\n// You _must_ export a single `test` function for the runner to execute.\nuse extism_pdk::*;\nuse xtp_test;\n\n#[derive(serde::Serialize, serde::Deserialize)]\npub struct Count {\n    count: usize,\n    total: usize,\n    vowels: String,\n}\n\n#[plugin_fn]\npub fn test() -\u003e FnResult\u003c()\u003e {\n    // call a function from some Extism plugin (you'll link these up in the CLI command to run the test),\n    // passing in some data and getting back a string (`callString` is a helper for string output)\n    let Json(res): Json\u003cCount\u003e = xtp_test::call(\"count_vowels\", \"some input\")?;\n    // assert the count of the vowels is correct, giving the test case a name (which will be shown in the CLI output)\n    // using the macro version here will also capture filename and line number\n    xtp_test::assert_eq!(\"count_vowels of 'some input'\", res.count, 4);\n\n    // create a group of tests, which will be run together and reset after the group is complete\n    xtp_test::group(\"count_vowels maintains state\", || {\n        let mut accum_total = 0;\n        let expected_final_total = 12;\n        for i in 0..3 {\n            let Json(res): Json\u003cCount\u003e = xtp_test::call(\"count_vowels\", \"this is a test\")?;\n            accum_total += res.count;\n            xtp_test::assert_eq(\"total count increased\", accum_total, 4 * (i + 1));\n        }\n\n        xtp_test::assert_eq(\n            \"expected total at and of test\",\n            accum_total,\n            expected_final_total,\n        );\n        Ok(())\n    })?;\n\n    Ok(())\n}\n```\n\n## API Docs\n\nPlease see the [**`docs.rs`**](https://docs.rs/xtp-test) documentation page for\nfull details.\n\n## Usage\n\n**1. Create a Rust project using the XTP Test crate**\n\n```sh\ncargo new --lib rust-xtp-test\ncd rust-xtp-test\n# ensure you have `crate-type = [\"cdylib\"]` in your `[lib]` section of Cargo.toml\ncargo add xtp-test extism-pdk\n```\n\n**2. Write your test in Rust**\n\n```rust\nuse extism_pdk::*;\nuse xtp_test;\n\n// You _must_ export a single `test` function for the runner to execute.\n#[plugin_fn]\npub fn test() -\u003e FnResult\u003c()\u003e {\n    // call a function from the Extism plugin being tested\n    let example = xtp_test::call(\"example\", example_input)?;\n    // assert various things about the behavior and performance of the function call\n    xtp_test::assert_ne(\"example not null\", \u0026example, \"\");\n    // ...\n    Ok(())\n}\n```\n\n**3. Compile your test to .wasm:**\n\nEnsure you have the `wasm32-unknown-unknown` and/or `wasm32-wasi` targets\ninstalled via `rustup`, and run:\n\n```sh\ncargo build --target wasm32-unknown-unknown --release\n```\n\n**4. Run the test against your plugin:** Once you have your test code as a\n`.wasm` module, you can run the test against your plugin using the `xtp` CLI:\n\n### Install `xtp`\n\n```sh\ncurl https://static.dylibso.com/cli/install.sh | sudo sh\n```\n\n### Run the test suite\n\n```sh\nxtp plugin test ./plugin-*.wasm --with test.wasm --mock-host host.wasm\n#               ^^^^^^^^^^^^^^^        ^^^^^^^^^             ^^^^^^^^^\n#               your plugin(s)         test to run           optional mock host functions\n```\n\n**Note:** The optional mock host functions must be implemented as Extism\nplugins, whose exported functions match the host function signature imported by\nthe plugins being tested.\n\n## Need Help?\n\nPlease reach out via the\n[`#xtp` channel on Discord](https://discord.com/channels/1011124058408112148/1220464672784908358).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylibso%2Fxtp-test-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdylibso%2Fxtp-test-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylibso%2Fxtp-test-rust/lists"}