@@ -26,6 +26,10 @@ class ErrorHandling: XCTestCase {
26
26
27
27
// Tests for throwing assertion expressions
28
28
( " test_assertionExpressionCanThrow " , test_assertionExpressionCanThrow) ,
29
+
30
+ // Tests for XCTAssertNoThrow
31
+ ( " test_shouldNotThrowErrorDefiningSuccess " , test_shouldNotThrowErrorDefiningSuccess) ,
32
+ ( " test_shouldThrowErrorDefiningFailure " , test_shouldThrowErrorDefiningFailure) ,
29
33
]
30
34
} ( )
31
35
@@ -103,13 +107,28 @@ class ErrorHandling: XCTestCase {
103
107
func test_assertionExpressionCanThrow( ) {
104
108
XCTAssertEqual ( try functionThatShouldReturnButThrows ( ) , 1 )
105
109
}
110
+
111
+
112
+ // CHECK: Test Case 'ErrorHandling.test_shouldNotThrowErrorDefiningSuccess' started at \d+:\d+:\d+\.\d+
113
+ // CHECK: Test Case 'ErrorHandling.test_shouldNotThrowErrorDefiningSuccess' passed \(\d+\.\d+ seconds\)
114
+ func test_shouldNotThrowErrorDefiningSuccess( ) {
115
+ XCTAssertNoThrow ( try functionThatDoesNotThrowError ( ) )
116
+ }
117
+
118
+ // CHECK: Test Case 'ErrorHandling.test_shouldThrowErrorDefiningFailure' started at \d+:\d+:\d+\.\d+
119
+ // CHECK: .*/ErrorHandling/main.swift:[[@LINE+3]]: error: ErrorHandling.test_shouldThrowErrorDefiningFailure : XCTAssertNoThrow failed: threw error "anError\("an error message"\)" -
120
+ // CHECK: Test Case 'ErrorHandling.test_shouldThrowErrorDefiningFailure' failed \(\d+\.\d+ seconds\)
121
+ func test_shouldThrowErrorDefiningFailure( ) {
122
+ XCTAssertNoThrow ( try functionThatDoesThrowError ( ) )
123
+ }
106
124
}
125
+
107
126
// CHECK: Test Suite 'ErrorHandling' failed at \d+:\d+:\d+\.\d+
108
- // CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
127
+ // CHECK: \t Executed \d+ tests, with \d+ failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
109
128
110
129
XCTMain ( [ testCase ( ErrorHandling . allTests) ] )
111
130
112
131
// CHECK: Test Suite '.*\.xctest' failed at \d+:\d+:\d+\.\d+
113
- // CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
132
+ // CHECK: \t Executed \d+ tests, with \d+ failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
114
133
// CHECK: Test Suite 'All tests' failed at \d+:\d+:\d+\.\d+
115
- // CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
134
+ // CHECK: \t Executed \d+ tests, with \d+ failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
0 commit comments