December 2018
Intermediate to advanced
414 pages
10h 19m
English
If we look now at the tests, we can see that all the tests start with the same instruction, which adds a 2. Let's refactor the tests removing the common instruction from each test. In the XCTestCase class, a function named setup() is called before each test, and it looks like we can move that instruction in that function:
override func setUp() { super.setUp() rpnCalculator.new(element: "2") }
However, now the test names are a bit misleading and it would be better to express the fact that all these tests have one thing in common. The thing they have in common is that the first element is the number 2: this defines the context of the suite. It could be helpful to use a trick to name the class to express that context: ...
Read now
Unlock full access