10
10
11
11
@testable @_spi ( Experimental) @_spi ( ForToolsIntegrationOnly) import Testing
12
12
13
- struct `Attachment.ConditionalRecordingTrait tests` {
14
- func runRecordingAttachmentTests ( with trait: AttachmentSavingTrait ? , expectedCount: Int , expectedIssueCount: Int = Self . issueCountFromTestBodies, expectedPreferredName: String ? ) async throws {
15
- let traitToApply = trait as ( any SuiteTrait ) ? ?? Self . currentRecordingAttachmentsTrait
16
- try await Self . $currentRecordingAttachmentsTrait . withValue ( traitToApply) {
13
+ struct `AttachmentSavingTrait tests` {
14
+ func runAttachmentSavingTests ( with trait: AttachmentSavingTrait ? , expectedCount: Int , expectedIssueCount: Int = Self . issueCountFromTestBodies, expectedPreferredName: String ? ) async throws {
15
+ let traitToApply = trait as ( any SuiteTrait ) ? ?? Self . currentAttachmentSavingTrait
16
+ try await Self . $currentAttachmentSavingTrait . withValue ( traitToApply) {
17
17
try await confirmation ( " Issue recorded " , expectedCount: expectedIssueCount) { issueRecorded in
18
18
try await confirmation ( " Attachment detected " , expectedCount: expectedCount) { valueAttached in
19
19
var configuration = Configuration ( )
@@ -41,62 +41,62 @@ struct `Attachment.ConditionalRecordingTrait tests` {
41
41
}
42
42
}
43
43
44
- @Test func `Recording attachments without conditions`() async throws {
45
- try await runRecordingAttachmentTests (
44
+ @Test func `Saving attachments without conditions`() async throws {
45
+ try await runAttachmentSavingTests (
46
46
with: nil ,
47
47
expectedCount: Self . totalTestCaseCount,
48
48
expectedPreferredName: nil
49
49
)
50
50
}
51
51
52
- @Test func `Recording attachments only on test pass`() async throws {
53
- try await runRecordingAttachmentTests (
52
+ @Test func `Saving attachments only on test pass`() async throws {
53
+ try await runAttachmentSavingTests (
54
54
with: . savingAttachments( if: . testPasses) ,
55
55
expectedCount: Self . passingTestCaseCount,
56
56
expectedPreferredName: " PASSING TEST "
57
57
)
58
58
}
59
59
60
- @Test func `Recording attachments only on test failure`() async throws {
61
- try await runRecordingAttachmentTests (
60
+ @Test func `Saving attachments only on test failure`() async throws {
61
+ try await runAttachmentSavingTests (
62
62
with: . savingAttachments( if: . testFails) ,
63
63
expectedCount: Self . failingTestCaseCount,
64
64
expectedPreferredName: " FAILING TEST "
65
65
)
66
66
}
67
67
68
- @Test func `Recording attachments with custom condition`() async throws {
69
- try await runRecordingAttachmentTests (
68
+ @Test func `Saving attachments with custom condition`() async throws {
69
+ try await runAttachmentSavingTests (
70
70
with: . savingAttachments( if: true ) ,
71
71
expectedCount: Self . totalTestCaseCount,
72
72
expectedPreferredName: nil
73
73
)
74
74
75
- try await runRecordingAttachmentTests (
75
+ try await runAttachmentSavingTests (
76
76
with: . savingAttachments( if: false ) ,
77
77
expectedCount: 0 ,
78
78
expectedPreferredName: nil
79
79
)
80
80
}
81
81
82
- @Test func `Recording attachments with custom async condition`() async throws {
82
+ @Test func `Saving attachments with custom async condition`() async throws {
83
83
@Sendable func conditionFunction( ) async -> Bool {
84
84
true
85
85
}
86
86
87
- try await runRecordingAttachmentTests (
87
+ try await runAttachmentSavingTests (
88
88
with: . savingAttachments( if: conditionFunction) ,
89
89
expectedCount: Self . totalTestCaseCount,
90
90
expectedPreferredName: nil
91
91
)
92
92
}
93
93
94
- @Test func `Recording attachments but the condition throws`() async throws {
94
+ @Test func `Saving attachments but the condition throws`() async throws {
95
95
@Sendable func conditionFunction( ) throws -> Bool {
96
96
throw MyError ( )
97
97
}
98
98
99
- try await runRecordingAttachmentTests (
99
+ try await runAttachmentSavingTests (
100
100
with: . savingAttachments( if: conditionFunction) ,
101
101
expectedCount: 0 ,
102
102
expectedIssueCount: Self . issueCountFromTestBodies + Self. totalTestCaseCount /* thrown from conditionFunction */,
@@ -107,16 +107,16 @@ struct `Attachment.ConditionalRecordingTrait tests` {
107
107
108
108
// MARK: - Fixtures
109
109
110
- extension `Attachment.ConditionalRecordingTrait tests` {
110
+ extension `AttachmentSavingTrait tests` {
111
111
static let totalTestCaseCount = 1 + 1 + 5 + 7
112
112
static let passingTestCaseCount = 1 + 5
113
113
static let failingTestCaseCount = 1 + 7
114
114
static let issueCountFromTestBodies = failingTestCaseCount
115
115
116
116
@TaskLocal
117
- static var currentRecordingAttachmentsTrait : any SuiteTrait = Comment ( rawValue: " <no .recordingAttachments trait set> " )
117
+ static var currentAttachmentSavingTrait : any SuiteTrait = Comment ( rawValue: " <no .savingAttachments trait set> " )
118
118
119
- @Suite ( . hidden, currentRecordingAttachmentsTrait )
119
+ @Suite ( . hidden, currentAttachmentSavingTrait )
120
120
struct FixtureSuite {
121
121
@Test ( . hidden) func `Records an attachment ( passing) `() {
122
122
Attachment . record ( " " , named: " PASSING TEST " )
0 commit comments