diff --git a/README.md b/README.md index 220b12c..2e9740d 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,7 @@ func test_iCanSeeTheStars() { } } ``` + +--- + +Example Output in the Report navigator diff --git a/Resources/test-output.png b/Resources/test-output.png new file mode 100644 index 0000000..be00d1a Binary files /dev/null and b/Resources/test-output.png differ diff --git a/Sources/Rorschach/Assertion.swift b/Sources/Rorschach/Assertion.swift index 7eeb0f5..a8257e9 100644 --- a/Sources/Rorschach/Assertion.swift +++ b/Sources/Rorschach/Assertion.swift @@ -11,5 +11,9 @@ open class Assertion { public init() {} + open var title: String { + "\(type(of: self))" + } + open func assert(in context: C) {} } diff --git a/Sources/Rorschach/Given.swift b/Sources/Rorschach/Given.swift index 41bb8b5..a65f87e 100644 --- a/Sources/Rorschach/Given.swift +++ b/Sources/Rorschach/Given.swift @@ -6,6 +6,7 @@ // import Foundation +import XCTest public class Given { @@ -24,6 +25,10 @@ public class Given { } func execute(in context: inout C) { - steps.forEach { $0.execute(in: &context) } + steps.forEach { step in + XCTContext.runActivity(named: step.title ) { _ in + step.execute(in: &context) + } + } } } diff --git a/Sources/Rorschach/Step.swift b/Sources/Rorschach/Step.swift index dab54b5..2e583d4 100644 --- a/Sources/Rorschach/Step.swift +++ b/Sources/Rorschach/Step.swift @@ -11,5 +11,9 @@ open class Step { public init() {} + open var title: String { + "\(type(of: self))" + } + open func execute(in context: inout C) {} } diff --git a/Sources/Rorschach/Test.swift b/Sources/Rorschach/Test.swift index 9dae748..e53c6f2 100644 --- a/Sources/Rorschach/Test.swift +++ b/Sources/Rorschach/Test.swift @@ -6,19 +6,30 @@ // import Foundation +import XCTest public func expect(in context: inout C, @TestBuilder _ content: () -> (given: Given, when: When, then: Then)) { - content().given.execute(in: &context) + XCTContext.runActivity(named: "Given" ) { _ in + content().given.execute(in: &context) + } - content().when.execute(in: &context) + XCTContext.runActivity(named: "When" ) { _ in + content().when.execute(in: &context) + } - content().then.assert(in: context) + XCTContext.runActivity(named: "Then" ) { _ in + content().then.assert(in: context) + } } public func expect(in context: inout C, @TestBuilder _ content: () -> (when: When, then: Then)) { - content().when.execute(in: &context) + XCTContext.runActivity(named: "When" ) { _ in + content().when.execute(in: &context) + } - content().then.assert(in: context) + XCTContext.runActivity(named: "Then" ) { _ in + content().then.assert(in: context) + } } diff --git a/Sources/Rorschach/Then.swift b/Sources/Rorschach/Then.swift index 4766712..ff64af7 100644 --- a/Sources/Rorschach/Then.swift +++ b/Sources/Rorschach/Then.swift @@ -6,6 +6,7 @@ // import Foundation +import XCTest public struct Then { @@ -16,6 +17,8 @@ public struct Then { } func assert(in context: C) { - assertion.assert(in: context) + XCTContext.runActivity(named: assertion.title) { _ in + assertion.assert(in: context) + } } } diff --git a/Sources/Rorschach/When.swift b/Sources/Rorschach/When.swift index 9f2a67a..f6b0c05 100644 --- a/Sources/Rorschach/When.swift +++ b/Sources/Rorschach/When.swift @@ -6,6 +6,7 @@ // import Foundation +import XCTest public struct When { @@ -16,7 +17,9 @@ public struct When { } func execute(in context: inout C) { - step.execute(in: &context) + XCTContext.runActivity(named: step.title) { activity in + step.execute(in: &context) + } } }