|
1 | | -import XCTest |
| 1 | +import Testing |
| 2 | +import Foundation |
2 | 3 | @testable import {{exercise|camelCase}} |
3 | | -class {{exercise|camelCase}}Tests: XCTestCase { |
4 | | - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
5 | 4 |
|
| 5 | +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
| 6 | + |
| 7 | +@Suite struct {{exercise|camelCase}}Tests { |
6 | 8 | {% outer: for case in cases %} |
7 | 9 | {%- for subCases in case.cases %} |
8 | 10 | {%- if forloop.outer.first and forloop.first %} |
9 | | - func test{{subCases.description |camelCase }}() { |
| 11 | + @Test("{{subCases.description}}") |
10 | 12 | {%- else %} |
11 | | - func test{{subCases.description |camelCase }}() throws { |
12 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 13 | + @Test("{{subCases.description}}", .enabled(if: RUNALL)) |
13 | 14 | {%- endif %} |
| 15 | + func test{{subCases.description |camelCase }}() { |
14 | 16 | {%- if subCases.property == "create" %} |
15 | | - XCTAssertEqual(Clock(hours: {{subCases.input.hour}}, minutes: {{subCases.input.minute}}).description, "{{subCases.expected}}") |
| 17 | + #expect(Clock(hours: {{subCases.input.hour}}, minutes: {{subCases.input.minute}}).description == "{{subCases.expected}}") |
16 | 18 | {%- elif subCases.property == "add"%} |
17 | 19 | let clock = Clock(hours: {{subCases.input.hour}}, minutes: {{subCases.input.minute}}).add(minutes: {{subCases.input.value}}) |
18 | | - XCTAssertEqual(clock.description, "{{subCases.expected}}") |
| 20 | + #expect(clock.description == "{{subCases.expected}}") |
19 | 21 | {%- elif subCases.property == "subtract" %} |
20 | 22 | let clock = Clock(hours: {{subCases.input.hour}}, minutes: {{subCases.input.minute}}).subtract(minutes: {{subCases.input.value}}) |
21 | | - XCTAssertEqual(clock.description, "{{subCases.expected}}") |
| 23 | + #expect(clock.description == "{{subCases.expected}}") |
22 | 24 | {%- elif subCases.property == "equal" %} |
23 | 25 | let clock1 = Clock(hours: {{subCases.input.clock1.hour}}, minutes: {{subCases.input.clock1.minute}}) |
24 | 26 | let clock2 = Clock(hours: {{subCases.input.clock2.hour}}, minutes: {{subCases.input.clock2.minute}}) |
25 | 27 | {%- if subCases.expected %} |
26 | | - XCTAssertEqual(clock1, clock2) |
| 28 | + #expect(clock1 == clock2) |
27 | 29 | {%- else %} |
28 | | - XCTAssertNotEqual(clock1, clock2) |
| 30 | + #expect(clock1 != clock2) |
29 | 31 | {%- endif %} |
30 | 32 | {%- endif %} |
31 | 33 | } |
|
0 commit comments