{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Unity Test Framework Features | Test Framework | 2.0.1-exp.2
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Unity Test Framework Features

    Editor UI integration

    The Test Runner window integrated into the Editor (menu: Window > General > Test Runner) allows you to create and run your tests and the Inspector window lets you configure your test assemblies.

    Unity Test Runner window

    Test in Edit Mode and Play Mode

    Unity Test Framework supports two test modes: Edit Mode tests to test your Editor extensions and game logic and Play Mode tests to test your Runtime game code. See Edit Mode vs. Play Mode tests for an overview.

    Custom attributes and NUnit extensions

    Unity Test Framework offers a range of custom Unity attributes that supplement or extend NUnit APIs:

    Skip frames and yield instructions in tests

    Unity Test Framework extends the NUnit Test attribute with a custom UnityTest attribute which allows you to skip frames and yield instructions for the Editor. See UnityTestAttribute in the Scripting API.

    Setup and Cleanup at build time

    Unity Test Framework provides pre-build setup and cleanup attributes to allow you to make changes to Unity or the file system before tests build and clean them up after. See Setup and cleanup at build time.

    Actions outside tests

    Unity Test Framework extends the NUnit options for performing actions in the setup and teardown phase with custom Unity attributes that allow yield instructions and an outer test action interface. See Actions outside tests.

    Equality comparers

    Unity Test Framework offers a range of custom equality comparers for Color, Float, Quaternion, Vector2, Vector3, and Vector 4 comparisons. See UnityEngine.TestTools.Utils in the Scripting API.

    Custom yield instructions

    Unity Test Framework provides custom yield instructions so your Edit Mode tests can instruct Unity to enter or exit Play Mode, recompile scripts, or wait for a domain reload. See IEditModeTestYieldInstruction in the scripting API.

    Custom assertion

    Unity Test Framework offers a custom assertion that allows your tests to expect specific messages in the Unity logs. See LogAssert in the Scripting API.

    Custom constraints

    Unity Test Framework extends the NUnit Assert.That mechanism with our own custom constraint type. See Constraints in the Scripting API.

    Parameterized tests

    Unity Test Framework supports parameterized tests for data-driven testing. See Parameterized tests.

    Monobehavior tests

    Unity Test Framework offers a coroutine wrapper to help you test Monobehaviors. See MonobehaviourTest in the Scripting API.

    Run tests programmatically

    Unity Test Framework provides a custom ScriptableObject with which you can retrieve and run tests programmatically from code in your project or another package. The API includes classes to filter which tests to run and to receive callbacks during the test run. See the TestRunnerApi Scripting API.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)