{!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} Workflow: How to create a Play Mode test | Test Framework | 1.3.9
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Workflow: How to create a Play Mode test

    To create a Play Mode test, you can follow a similar process as when you want to create an Edit Mode test.

    1. Start with switching to the PlayMode tab in the Test Runner window.
    2. Create a test assembly folder (see How to create a new test assembly). The folder name is Tests by default (or Tests 1, Tests 2, etc. if the preceding name is already in use).

    PlayMode tab

    Note: If you don’t see the Create Play Mode Test Assembly Folder button enabled, make sure that in the Project window you navigate out of a folder with another .asmdef (such as one for Edit Mode tests).

    1. When you have your Play Mode test assembly folder ready, then create your Play Mode test.

    Note: Pre-defined Unity assemblies (such as Assembly-CSharp.dll) do not reference your new assembly.

    References and builds

    Unity Test Framework adds a reference to TestAssemblies in the Assembly Definition file but does not include any other references (e.g., to other scripting assemblies within the Unity project). To test other assemblies, you need to add them to the assembly definition yourself. For how to add assembly references, see Assembly Definition. We recommend putting tests into separate assemblies and using assembly definitions files. This way you will have more control over which assemblies need to reference test related dlls.

    Playmode build with TestsAssemblies

    Note: Enabling Play Mode tests for all assemblies includes additional assemblies in your project build, which can increase the project’s size as well as the build time.

    The supported workflow is to exclude TestAssemblies from Player builds. You can choose to enable playmode tests for all assemblies to run your tests inside the Editor, but this should be disabled again before building the Player to prevent build failures.

    To enable play mode tests for all assemblies you need to set the flag playModeTestRunnerEnabled to 1 inside the ProjectSettings/ProjectSetting.asset file in your project. Before building the Player you must disable it again by setting the flag back to 0.

    For more information, see Edit Mode vs. Play Mode tests.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • References and builds
      • Playmode build with TestsAssemblies
    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)