In many articles about TDD, you will find the term SUT, which refers to the System Under Test. Using SUT instead of the object’s name is especially helpful when the object’s setup is complex and requires a lot of other objects to be created. In this case, naming our object under test SUT will enhance readability by making it very easy to understand what object we test.
For example, the following test:
1 2 3 4 5 6 7 |
func test_fizzBuzz_whenInputIsMultipleOf3_returnsFizz() { let fizzBuzzCalculator = FizzBuzzCalculator() let result = fizzBuzzCalculator.fizzBuzz(number: anyIntAboveOne() * 3) XCTAssertEqual("Fizz", result) } |
can be written using the SUT term as follows:
1 2 3 4 5 6 7 |
func test_fizzBuzz_whenInputIsMultipleOf3_returnsFizz() { let sut = FizzBuzzCalculator() let result = sut.fizzBuzz(number: anyIntAboveOne() * 3) XCTAssertEqual("Fizz", result) } |