{"id":44044735,"url":"https://github.com/nowsprinting/test-helper.input","last_synced_at":"2026-02-07T21:36:05.785Z","repository":{"id":167579196,"uuid":"643199823","full_name":"nowsprinting/test-helper.input","owner":"nowsprinting","description":"Mocking the Input Manager (Legacy, UnityEngine.Input)","archived":false,"fork":false,"pushed_at":"2025-08-30T07:35:50.000Z","size":1135,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-30T09:19:23.175Z","etag":null,"topics":["testing","unity","unity3d"],"latest_commit_sha":null,"homepage":"https://nowsprinting.github.io/test-helper.input/","language":"C#","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/nowsprinting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-20T12:12:30.000Z","updated_at":"2025-08-30T07:35:53.000Z","dependencies_parsed_at":"2023-05-23T04:00:17.240Z","dependency_job_id":"8973f6d1-806b-4ea5-8879-74c7be4e6c6f","html_url":"https://github.com/nowsprinting/test-helper.input","commit_stats":null,"previous_names":["nowsprinting/test-helper.input"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nowsprinting/test-helper.input","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowsprinting%2Ftest-helper.input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowsprinting%2Ftest-helper.input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowsprinting%2Ftest-helper.input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowsprinting%2Ftest-helper.input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nowsprinting","download_url":"https://codeload.github.com/nowsprinting/test-helper.input/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nowsprinting%2Ftest-helper.input/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29208765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T21:35:21.898Z","status":"ssl_error","status_checked_at":"2026-02-07T21:35:20.106Z","response_time":63,"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":["testing","unity","unity3d"],"created_at":"2026-02-07T21:36:05.721Z","updated_at":"2026-02-07T21:36:05.775Z","avatar_url":"https://github.com/nowsprinting.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Input Test Helper\n\n[![Meta file check](https://github.com/nowsprinting/test-helper.input/actions/workflows/metacheck.yml/badge.svg)](https://github.com/nowsprinting/test-helper.input/actions/workflows/metacheck.yml)\n[![Test](https://github.com/nowsprinting/test-helper.input/actions/workflows/test.yml/badge.svg)](https://github.com/nowsprinting/test-helper.input/actions/workflows/test.yml)\n[![openupm](https://img.shields.io/npm/v/com.nowsprinting.test-helper.input?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.nowsprinting.test-helper.input/)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/nowsprinting/test-helper.input)\n\nLibrary for mocking the Input Manager (Legacy, [UnityEngine.Input](https://docs.unity3d.com/ScriptReference/Input.html)).  \nRequired Unity 2019 LTS or later.\n\n\n\n## Features\n\n### Mocking `UnityEngine.Input`\n\nThe `UnityEngine.Input` class provides static methods.\nYou can inject test stubs into your tests by replacing `Input` with the `IInput` interface.\n\nUsage:\n\n#### 1. Insert the code below into your product code to replace `UnityEngine.Input` with a `TestHelper.Input.InputWrapper` instance\n\n```csharp\n#if UNITY_INCLUDE_TESTS\n    internal IInput Input { private get; set; } = new InputWrapper();\n#endif\n```\n\n\u003e [!TIP]  \n\u003e `InputWrapper` also works at runtime, but you can remove the `TestHelper.Input` assembly from the build using the `#if UNITY_INCLUDE_TESTS` directive.\n\n#### 2. Create test stub in your test\n\n```csharp\npublic class StubInput : InputWrapper\n{\n    public KeyCode[] PushedKeys { get; set; } = Array.Empty\u003cKeyCode\u003e();\n\n    public override bool GetKey(KeyCode key)\n    {\n        return PushedKeys.Contains(key);\n    }\n}\n```\n\n#### 3. Write test using test stub\n\n```csharp\n[UnityTest]\npublic IEnumerator PushW_MoveForward()\n{\n    var sut = new GameObject().AddComponent\u003cSUT\u003e();\n    var stub = new StubInput();\n    sut.Input = stub; // Inject test stub\n\n    stub.PushedKeys = new[] { KeyCode.W }; // Push W key\n    yield return new WaitForSeconds(0.5f);\n    stub.PushedKeys = Array.Empty\u003cKeyCode\u003e(); // Release key\n\n    var actual = sut.transform.position;\n    Assert.That(actual, Is.EqualTo(new Vector3(0f, 0f, 4f))\n        .Using(new Vector3EqualityComparer(0.3f)));\n}\n```\n\n\n\n## Installation\n\n### 1. Install via Package Manager window\n\n1. Open the Project Settings window (**Editor \u003e Project Settings**) and select **Package Manager** tab (figure 1.)\n2. Click **+** button under the **Scoped Registries** and enter the following settings:\n    1. **Name:** `package.openupm.com`\n    2. **URL:** `https://package.openupm.com`\n    3. **Scope(s):** `com.nowsprinting`\n3. Open the Package Manager window (**Window \u003e Package Manager**) and select **My Registries** tab (figure 2.)\n4. Select **Input Test Helper** and click the **Install** button\n\n**Figure 1.** Scoped Registries setting in Project Settings window\n\n![](Documentation~/ScopedRegistries_Dark.png#gh-dark-mode-only)\n![](Documentation~/ScopedRegistries_Light.png#gh-light-mode-only)\n\n**Figure 2.** My Registries in Package Manager window\n\n![](Documentation~/PackageManager_Dark.png#gh-dark-mode-only)\n![](Documentation~/PackageManager_Light.png#gh-light-mode-only)\n\n\n### 2. Add assembly reference\n\n1. Open your product and test assembly definition file (.asmdef) in **Inspector** window\n2. Add **TestHelper.Input** into **Assembly Definition References**\n\n\n\n## License\n\nMIT License\n\n\n## How to contribute\n\nOpen an issue or create a pull request.\n\nBe grateful if you could label the PR as `enhancement`, `bug`, `chore`, and `documentation`.\nSee [PR Labeler settings](.github/pr-labeler.yml) for automatically labeling from the branch name.\n\n\n## How to development\n\n### Clone repo as a embedded package\n\nAdd this repository as a submodule to the Packages/ directory in your project.\n\nRun the command below:\n\n```bash\ngit submodule add git@github.com:nowsprinting/test-helper.input.git Packages/com.nowsprinting.test-helper.input\n```\n\n\n### Run tests\n\nGenerate a temporary project and run tests on each Unity version from the command line.\n\n```bash\nmake create_project\nUNITY_VERSION=2019.4.40f1 make -k test\n```\n\n\u003e [!WARNING]  \n\u003e You must select \"Input Manager (Old)\" or \"Both\" in the **Project Settings \u003e Player \u003e Active Input Handling** for running tests.\n\n\n### Release workflow\n\nThe release process is as follows:\n\n1. Run **Actions \u003e Create release pull request \u003e Run workflow**\n2. Merge created pull request\n\nThen, will do the release process automatically by [Release](.github/workflows/release.yml) workflow.\nAfter tagging, [OpenUPM](https://openupm.com/) retrieves the tag and updates it.\n\n\u003e [!CAUTION]  \n\u003e Do **NOT** manually operation the following operations:\n\u003e - Create a release tag\n\u003e - Publish draft releases\n\n\u003e [!CAUTION]  \n\u003e You must modify the package name to publish a forked package.\n\n\u003e [!TIP]  \n\u003e If you want to specify the version number to be released, change the version number of the draft release before running the \"Create release pull request\" workflow.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnowsprinting%2Ftest-helper.input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnowsprinting%2Ftest-helper.input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnowsprinting%2Ftest-helper.input/lists"}