             // Run the step
             state.currentStepDepth += 1
             state.currentStepLocation = (file, line)
+            if automaticScreenshotsBehaviour.contains(.beforeStep) {
+                attachScreenshot(name: "Before \"\(expression)\"")
+            }
             step.function(matchStrings)
+            if automaticScreenshotsBehaviour.contains(.afterStep) {
+                attachScreenshot(name: "After \"\(expression)\"")
+            }
             state.currentStepLocation = nil
             state.currentStepDepth -= 1
         }

        let line = Int(currentStepLocation.line)
        guard filePath != file, lineNumber != line else { return }
        test.recordFailure(withDescription: description, inFile: file, atLine: line, expected: false)
    }

    func gherkinStepsAndMatchesMatchingExpression(_ expression: String) -> [(step: Step, match: NSTextCheckingResult)] {

        }
    }
    
}

private var automaticScreenshotsBehaviour: AutomaticScreenshotsBehaviour = []

public struct AutomaticScreenshotsBehaviour: OptionSet {
    public let rawValue: Int
    public init(rawValue: Int) {
        self.rawValue = rawValue
    }

    public static let onFailure    = AutomaticScreenshotsBehaviour(rawValue: 1 << 0)
    public static let beforeStep   = AutomaticScreenshotsBehaviour(rawValue: 1 << 1)
    public static let afterStep    = AutomaticScreenshotsBehaviour(rawValue: 1 << 2)
}

extension XCTestCase {
    public static func setAutomaticScreenshotsBehaviour(_ behaviour: AutomaticScreenshotsBehaviour) {
        automaticScreenshotsBehaviour = behaviour
    }

    func attachScreenshot(name: String) {
        let screenshot = XCUIScreen.main.screenshot()
        let attachment = XCTAttachment(screenshot: screenshot)
        attachment.name = name
        add(attachment)
    }
}

/**
