To create and execute a unit test in PlayMode, follow these steps:
- Create a new 3D Unity project.
- In the Package Manager window, ensure you have the latest version of the Test Framework package installed.
- Display the Test Runner window by going to Window | General | Test Runner.
- Ensure that the PlayMode button is selected in the Test Runner window.
- In the Test Runner window, click the Create PlayMode Test Assembly Folder button. You'll now see a folder called Tests in the Project window.
- In the Test Runner window, click the Create Test Script in current folder button. Rename the script class PhysicsTestScript.cs and ensure it contains the following code:
using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
public class PhysicsTestScript
...