Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Tutorial] How to setup your project for unit testing

Discussion in 'General Discussion' started by charlesamat, Sep 27, 2019.

  1. charlesamat

    charlesamat

    Joined:
    Feb 5, 2014
    Posts:
    66
    The first step to testing your game is setting up the project for unit tests. Watch this Unity tutorial to learn how!



    Disclaimer - This is just ONE way to set up tests. If you have an alternative flow or structure please feel free to let everyone know in the comments

    TL;DW
    1. Right-Click in Project Panel, expand the Create -> Testing menu, and click on "Test Assembly Folder".
    2. Rename the new folder to "PlayMode".
    3. Create a new folder called "Tests" inside of the "Assets" folder.
    4. Drag the "PlayMode" folder into the "Tests" folder.
    5. Rename the Assembly Definition File inside of the "PlayMode" folder to "PlayModeTests".
    6. Open "PlayModeTests.asmdef" in the inspector, rename it to "PlayModeTests", and click Apply.
    7. Navigate to the top navigation menu, expand Window -> General, and click on "Test Runner".
    8. Dock the Test Runner window to your editor.
    9. Click on the "Assets" folder in the Project panel.
    10. Click on "EditMode" in the Test Runner Panel and then click on the "Create Test Script in current folder" button.
    11. Drag the new folder into the "Tests" folder.
    12. Rename the new folder to "EditMode".
    13. Rename the Assembly Definition File inside of the "EditMode" folder to "EditModeTests".
    14. Open "EditModeTests.asmdef" in the inspector, rename it to "EditModeTests", and click Apply.