Skip to content

Commit

Permalink
Update XCTestScenario.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
nshthshah authored Mar 19, 2024
1 parent 50bc6a9 commit b175f17
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Pod/XCTestExtension/XCTestScenario.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ public extension XCTestCase {
get { return XCTestCase._metadata ?? JsonType() }
set(metadata) { XCTestCase._metadata = metadata }
}


@discardableResult
func scenario(withMetadata metadata: JsonType = JsonType()) -> XCTestCase {
self.metadata = metadata
self.steps.removeAll()
self.state.currentStepDepth = 0
self.state.currentStepLocation = nil
return self
}

func execute() {
self.steps.forEach { step in
GherkinScenarioObservationCenter.shared.triggernotification(forState: .testStepWillStart(step))
Expand All @@ -45,25 +46,29 @@ public extension XCTestCase {
GherkinScenarioObservationCenter.shared.triggernotification(forState: .testStepDidFinish(step))
}
}


@discardableResult
func given(_ expression: String, file: String = #file, line: Int = #line) -> XCTestCase {
let step = GherkinStep(expression, keyword: "Given", file: file, line: line)
self.steps.append(step)
return self
}


@discardableResult
func when(_ expression: String, file: String = #file, line: Int = #line) -> XCTestCase {
let step = GherkinStep(expression, keyword: "When", file: file, line: line)
self.steps.append(step)
return self
}


@discardableResult
func then(_ expression: String, file: String = #file, line: Int = #line) -> XCTestCase {
let step = GherkinStep(expression, keyword: "Then", file: file, line: line)
self.steps.append(step)
return self
}


@discardableResult
func and(_ expression: String, file: String = #file, line: Int = #line) -> XCTestCase {
let step = GherkinStep(expression, keyword: "And", file: file, line: line)
self.steps.append(step)
Expand Down

0 comments on commit b175f17

Please sign in to comment.