|
| 1 | +// RUN: %{swiftc} %s -o %{built_tests_dir}/FailingTestSuite |
| 2 | +// RUN: %{built_tests_dir}/FailingTestSuite > %t || true |
| 3 | +// RUN: %{xctest_checker} %t %s |
| 4 | +// CHECK: Test Case 'PassingTestCase.test_passes' started. |
| 5 | +// CHECK: Test Case 'PassingTestCase.test_passes' passed \(\d+\.\d+ seconds\). |
| 6 | +// CHECK: Executed 1 test, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds |
| 7 | +// CHECK: Test Case 'FailingTestCase.test_passes' started. |
| 8 | +// CHECK: Test Case 'FailingTestCase.test_passes' passed \(\d+\.\d+ seconds\). |
| 9 | +// CHECK: Test Case 'FailingTestCase.test_fails' started. |
| 10 | +// CHECK: .*/Tests/Functional/FailingTestSuite/main.swift:50: error: FailingTestCase.test_fails : XCTAssertTrue failed - $ |
| 11 | +// CHECK: Test Case 'FailingTestCase.test_fails' failed \(\d+\.\d+ seconds\). |
| 12 | +// CHECK: Test Case 'FailingTestCase.test_fails_with_message' started. |
| 13 | +// CHECK: .*/Tests/Functional/FailingTestSuite/main.swift:54: error: FailingTestCase.test_fails_with_message : XCTAssertTrue failed - Foo bar. |
| 14 | +// CHECK: Test Case 'FailingTestCase.test_fails_with_message' failed \(\d+\.\d+ seconds\). |
| 15 | +// CHECK: Executed 3 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds |
| 16 | +// CHECK: Total executed 2 tests, with 2 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds |
| 17 | + |
| 18 | +#if os(Linux) || os(FreeBSD) |
| 19 | + import XCTest |
| 20 | +#else |
| 21 | + import SwiftXCTest |
| 22 | +#endif |
| 23 | + |
| 24 | +class PassingTestCase: XCTestCase { |
| 25 | + var allTests: [(String, () -> ())] { |
| 26 | + return [ |
| 27 | + ("test_passes", test_passes), |
| 28 | + ] |
| 29 | + } |
| 30 | + |
| 31 | + func test_passes() { |
| 32 | + XCTAssert(true) |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +class FailingTestCase: XCTestCase { |
| 37 | + var allTests: [(String, () -> ())] { |
| 38 | + return [ |
| 39 | + ("test_passes", test_passes), |
| 40 | + ("test_fails", test_fails), |
| 41 | + ("test_fails_with_message", test_fails_with_message), |
| 42 | + ] |
| 43 | + } |
| 44 | + |
| 45 | + func test_passes() { |
| 46 | + XCTAssert(true) |
| 47 | + } |
| 48 | + |
| 49 | + func test_fails() { |
| 50 | + XCTAssert(false) |
| 51 | + } |
| 52 | + |
| 53 | + func test_fails_with_message() { |
| 54 | + XCTAssert(false, "Foo bar.") |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +XCTMain([ |
| 59 | + PassingTestCase(), |
| 60 | + FailingTestCase(), |
| 61 | +]) |
0 commit comments