ターゲットクラスのregisterUndoではundo操作に分かりやすいようprintを入れています。
テストクラスではご覧の通りundoを一回しか呼んでいませんが、コンソールには"undo is executed"が3回表示され、実際にcountも0まで戻ってしまいます。
コンソールログ
Test Case '-[UnitTestProjectTests.UnitTestProjectTests testUndo]' started.
undo is executed
undo is executed
undo is executed
/Users/project/UnitTestProject/UnitTestProjectTests/UnitTestProjectTests.swift:27: error: -[UnitTestProjectTests.UnitTestProjectTests testUndo] : XCTAssertEqual failed: ("0") is not equal to ("2")
Test Case '-[UnitTestProjectTests.UnitTestProjectTests testUndo]' failed (0.019 seconds).
Test Suite 'UnitTestProjectTests' failed at 2021-01-04 22:21:43.585.
Executed 1 test, with 1 failure (0 unexpected) in 0.019 (0.020) seconds
Test Suite 'UnitTestProjectTests.xctest' failed at 2021-01-04 22:21:43.585.
Executed 1 test, with 1 failure (0 unexpected) in 0.019 (0.021) seconds
Test Suite 'Selected tests' failed at 2021-01-04 22:21:43.586.
Executed 1 test, with 1 failure (0 unexpected) in 0.019 (0.023) seconds
1increment()
2opening group at level 0
3closing group at level 0
4increment()
5opening group at level 0
6closing group at level 0
7decrement()
8opening group at level 0
9closing group at level 0
10Undo
11increment()
12Undo
13decrement()
14Undo
15decrement()
16Redo
17increment()
18Redo
19increment()
20increment()
21opening group at level 0
22closing group at level 0
23Cannot redo
24Undo
25decrement()