{"id":13663370,"url":"https://github.com/Cysharp/RuntimeUnitTestToolkit","last_synced_at":"2025-04-25T13:33:06.121Z","repository":{"id":43293364,"uuid":"83943290","full_name":"Cysharp/RuntimeUnitTestToolkit","owner":"Cysharp","description":"CLI/GUI Frontend of Unity Test Runner to test on any platform.","archived":false,"fork":false,"pushed_at":"2025-03-19T06:41:40.000Z","size":235,"stargazers_count":310,"open_issues_count":1,"forks_count":23,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-12T08:17:58.000Z","etag":null,"topics":["csharp","il2cpp","testing-tools","unit-testing","unity"],"latest_commit_sha":null,"homepage":"","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/Cysharp.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,"zenodo":null}},"created_at":"2017-03-05T03:58:53.000Z","updated_at":"2025-04-04T03:05:31.000Z","dependencies_parsed_at":"2024-04-17T10:38:50.931Z","dependency_job_id":"64b8188d-f618-4900-a7cd-506946f479cd","html_url":"https://github.com/Cysharp/RuntimeUnitTestToolkit","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FRuntimeUnitTestToolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FRuntimeUnitTestToolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FRuntimeUnitTestToolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FRuntimeUnitTestToolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cysharp","download_url":"https://codeload.github.com/Cysharp/RuntimeUnitTestToolkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250825195,"owners_count":21493407,"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":["csharp","il2cpp","testing-tools","unit-testing","unity"],"created_at":"2024-08-02T05:02:25.701Z","updated_at":"2025-04-25T13:33:01.059Z","avatar_url":"https://github.com/Cysharp.png","language":"C#","funding_links":[],"categories":["C\\#","C#"],"sub_categories":[],"readme":"RuntimeUnitTestToolkit(v2)\n===\n[![Build-Debug](https://github.com/Cysharp/RuntimeUnitTestToolkit/actions/workflows/build-debug.yml/badge.svg)](https://github.com/Cysharp/RuntimeUnitTestToolkit/actions/workflows/build-debug.yml) [![Releases](https://img.shields.io/github/release/Cysharp/RuntimeUnitTestToolkit.svg)](https://github.com/Cysharp/RuntimeUnitTestToolkit/releases)\n\nRuntimeUnitTestToolkit is the supplement of [Unity Test Runner](https://docs.unity3d.com/Manual/testing-editortestsrunner.html). Unity Test Runner works fine but player runner(any target platform) is very poor. RuntimeUnitTestToolkit provides CLI(for run on CI) and GUI(for run on any platforms(Windows, Mac, iOS, Android, etc...)) frontend of Unity Test Runner.\n\nYou can write test that work on Unity Test Runner, it also can build runtime player by RuntimeUnitTestToolkit.\n\n![image](https://user-images.githubusercontent.com/46207/57200330-a04aae00-6fc5-11e9-82fa-39006fef583e.png)\n\nChoose the settings(ScriptBackend - `Mono` or `IL2CPP`, BuildTarget, CLI(Headless) or GUI) and select `BuildUnitTest`.\n\n![image](https://user-images.githubusercontent.com/46207/57200618-29afaf80-6fc9-11e9-8515-167076b2f4d8.png)\n\nYou can see the test result of CUI(Headless) player or\n\n![image](https://user-images.githubusercontent.com/46207/57200784-d2aada00-6fca-11e9-8182-944abb963316.png)\n\nGUI player on your built platforms.\n\nThe test is same as listed on Unity Test Runner's PlayMode tests.\n\n![image](https://user-images.githubusercontent.com/46207/57200806-27e6eb80-6fcb-11e9-9d86-dfe6c7a854c6.png)\n\nTarget test allows asmdef's Test Assemblies so does not includes test files when standard build(but include when build by RuntimeUnitTestToolkit automatically).\n\nOn CI(use CLI(Headless) mode), if fail the test, shows red. You can notify to Slack or other communication tools by CI's integration.\n\n![image](https://user-images.githubusercontent.com/46207/57200862-d12de180-6fcb-11e9-8353-5a897dd2c952.png)\n\nYou can also use GUI test on UnityEditor, choose `LoadUnitTestScene` and play.\n\n![image](https://user-images.githubusercontent.com/46207/80211233-4af12c00-8670-11ea-9c7c-29fb43d3031c.png)\n\nInstall\n---\n`RuntimeUnitTestToolkit.*version*.unitypackage` on [releases](https://github.com/Cysharp/RuntimeUnitTestToolkit/releases) page or `package.json` exists on `RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit` for package manager.\n\nAfter Unity 2019.3.4f1, Unity 2020.1a21, that support path query parameter of git package. You can add `https://github.com/Cysharp/RuntimeUnitTestToolkit.git?path=RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit` to Package Manager UI.\n\nOr add `\"com.cysharp.runtimeunittesttoolkit\": \"https://github.com/Cysharp/RuntimeUnitTestToolkit.git?path=RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit\"` to `Packages/manifest.json`.\n\nIf you want to set a target version, RuntimeUnitTestToolkit is using `*.*.*` release tag so you can specify a version like `#2.6.0`. For example `https://github.com/Cysharp/RuntimeUnitTestToolkit.git?path=RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit#2.6.0`.\n\nCommandLine Reference\n---\nFor example, this library's CI(GitHub Actions) itself.\n\n```yml\n# Execute scripts: RuntimeUnitTestToolkit(Linux64/Mono2x)\n- name: Build UnitTest(Linux64, mono)\n  run: /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend Mono2x /BuildTarget StandaloneLinux64\n  working-directory: RuntimeUnitTestToolkit\n\n# Execute player:\n- name: Execute UnitTest\n  run: ./RuntimeUnitTestToolkit/bin/UnitTest/StandaloneLinux64_Mono2x/test\n```\n\n```yml\n# Execute scripts: RuntimeUnitTestToolkit(Linux64/IL2CPP)\n- name: Build UnitTest(Linux64, il2cpp)\n  run: /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64\n  working-directory: RuntimeUnitTestToolkit\n\n# Execute player:\n- name: Execute UnitTest\n  run: ./RuntimeUnitTestToolkit/bin/UnitTest/StandaloneLinux64_IL2CPP/test\n```\n\nYou can invoke `-executeMethod UnitTestBuilder.BuildUnitTest` and some options.\n\n| Command        | Desc |\n| ---            | ---  |\n| **/headless**      | Boolean switch, build CLI mode. Default is false. |\n| **/scriptBackend** ScriptingImplementation | Enum string(`Mono2x` or `IL2CPP` or `WinRTDotNET` )|\n| **/buildTarget** BuildTarget   |Enum string(`StandaloneWindows64`, `StandaloneLinux64`, `StandaloneOSX`, `iOS`, `Android`, etc...) |\n| **/buildPath** FilePath    | String path. Default is `bin/UnitTest/{BuildTarget}_{ScriptBackend}/test`(If windows `test.exe`, Android `test.apk`, OSX `test.app`) |\n\nYou can pass by `/` prefix.\n\nAttribute\n---\nRuntimeUnitTestToolkit supports these attributes.\n\n* SetUp\n* TearDown\n* Test\n* UnityTest\n* TestCase\n* TestCaseSource\n* OneTimeSetUp\n* OneTimeTearDown\n* SetUpFixture\n* UnitySetUp\n* UnityTearDown\n\nAsync Test\n---\nUnity's `[UnityTest]`, `[UnitySetup]`, `[UnityTearDown]` attribute can test coroutine(IEnumerator) but can not test async. [Cysharp/UniTask](https://github.com/Cysharp/UniTask) and `UniTask.ToCoroutine` bridges async/await to coroutine so you can test async method.\n\n```csharp\n[UnityTest]\npublic IEnumerator DelayIgnore() =\u003e UniTask.ToCoroutine(async () =\u003e\n{\n    var time = Time.realtimeSinceStartup;\n\n    Time.timeScale = 0.5f;\n    try\n    {\n        await UniTask.Delay(TimeSpan.FromSeconds(3), ignoreTimeScale: true);\n\n        var elapsed = Time.realtimeSinceStartup - time;\n        Assert.AreEqual(3, (int)Math.Round(TimeSpan.FromSeconds(elapsed).TotalSeconds, MidpointRounding.ToEven));\n    }\n    finally\n    {\n        Time.timeScale = 1.0f;\n    }\n});\n```\n\nAdvanced\n---\n\n### How to get stdout/stderr \u0026 ExitCode with StandaloneOSX w/Headless\n\n`/headless` argument offer CUI player, therefore user can handle stdout/stderr and ExitCode on CI.\n\nHowever you will find it's not for StandaloneOSX. `BuildUnitTest` on StandaloneOSX generate `.app` but you cannot get any output or ExitCode with `open -a xxxx.app`\nLet's see what going on with this repository's UnitTest.\n\n```shell\n$ cd ./RuntimeUnitTestToolkit\n$ /Applications/Unity/Hub/Editor/2018.3.9f1/Unity.app/Contents/MacOS/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend Mono2x /BuildTarget StandaloneOSX\n# nothind will output\n$ open -a ./bin/UnitTest/StandaloneOSX_Mono2x/test.app\n# always exitcode is 0, even if test failed.\n$ echo $?\n0\n```\n\n**Trick**\n\nYou can obtain stdout/stderr and ExitCode by executing actual binary inside xxxx.app.\n\n\u003e binary path is always `xxxx.app/Contents/MacOS/YOUR_APP_NAME` in StandaloneOSX.\n\nTry open terminal and call binary, then you will find expected output.\n\n```shell\n$ ./bin/UnitTest/StandaloneOSX_Mono2x/test.app/Contents/MacOS/RuntimeUnitTestToolkit\n```\n\n![image](https://user-images.githubusercontent.com/3856350/80474748-cf022700-8982-11ea-8c56-45e9cd0e1bb5.png)\n\nYou can Pipe as usual. ExitCode will be `0` when test success, and `1` for failed.\n\n```shell\n$ ./test.app/Contents/MacOS/RuntimeUnitTestToolkit | grep OK\n[OK]SumTest, 14.30ms\n[OK]AsyncTest, 1039.78ms\n```\n\n![image](https://user-images.githubusercontent.com/3856350/80474656-ad08a480-8982-11ea-9e6b-38f9e5539d26.png)\n\n![image](https://user-images.githubusercontent.com/3856350/80474554-8d717c00-8982-11ea-9d7e-aafdf19b0717.png)\n\n\nLicense\n---\nThis library is under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCysharp%2FRuntimeUnitTestToolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCysharp%2FRuntimeUnitTestToolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCysharp%2FRuntimeUnitTestToolkit/lists"}