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 executed for those learning unit testing. That's what we'll create in this recipe:
A simple unit test
How to do it...
To create and execute a simple unit test, follow these steps:
- In the Project panel, create a folder called Editor.
- Inside your Editor folder, create a new C# SimpleTester.cs script class containing the following:
using NUnit.Framework;
class SimpleTester
{
[Test]
public void TestOnePlusOneEqualsTwo()
{
// Arrange
int n1 = 1;
int n2 = 1;
int expectedResult...