Making a simple unit test
In the same way as printing “hello world” is most programmers’ first program statement, asserting that 1 + 1 = 2 is perhaps the most common first test that’s executed for those learning unit testing. That’s what we’ll create in this recipe:
Figure 19.9: Our simple numeric test method passing with a green tick
How to do it...
To create and execute a simple unit test, follow these steps:
- Create a new 3D Unity project.
- Display the Test Runner panel by going to Window | General | Test Runner.
- Ensure that the EditMode button is selected in the Test Runner panel.
- In the Test Runner panel, click the Create EditMode Test Assembly Folder button. You’ll now see a folder called
Tests
that’s been created in the Project panel. - Select the
Tests
folder. - In the Test Runner panel, click the Create Test Script in current folder button.
- You should now have...