1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//
// XCTestObservation.swift
// Hooks for being notified about progress during a test run.
//
/// `XCTestObservation` provides hooks for being notified about progress during a
/// test run.
/// - seealso: `XCTestObservationCenter`
public protocol XCTestObservation: AnyObject {
/// Sent immediately before tests begin as a hook for any pre-testing setup.
/// - Parameter testBundle: The bundle containing the tests that were
/// executed.
func testBundleWillStart(_ testBundle: Bundle)
/// Sent when a test suite starts executing.
/// - Parameter testSuite: The test suite that started. Additional
/// information can be retrieved from the associated XCTestRun.
func testSuiteWillStart(_ testSuite: XCTestSuite)
/// Called just before a test begins executing.
/// - Parameter testCase: The test case that is about to start. Its `name`
/// property can be used to identify it.
func testCaseWillStart(_ testCase: XCTestCase)
/// Called when a test failure is reported.
/// - Parameter testCase: The test case that failed. Its `name` property
/// can be used to identify it.
/// - Parameter description: Details about the cause of the test failure.
/// - Parameter filePath: The path to the source file where the failure
/// was reported, if available.
/// - Parameter lineNumber: The line number in the source file where the
/// failure was reported.
func testCase(_ testCase: XCTestCase, didFailWithDescription description: String, inFile filePath: String?, atLine lineNumber: Int)
/// Called just after a test finishes executing.
/// - Parameter testCase: The test case that finished. Its `name` property
/// can be used to identify it.
func testCaseDidFinish(_ testCase: XCTestCase)
/// Sent when a test suite finishes executing.
/// - Parameter testSuite: The test suite that finished. Additional
/// information can be retrieved from the associated XCTestRun.
func testSuiteDidFinish(_ testSuite: XCTestSuite)
/// Sent immediately after all tests have finished as a hook for any
/// post-testing activity. The test process will generally exit after this
/// method returns, so if there is long running and/or asynchronous work to
/// be done after testing, be sure to implement this method in a way that
/// it blocks until all such activity is complete.
/// - Parameter testBundle: The bundle containing the tests that were
/// executed.
func testBundleDidFinish(_ testBundle: Bundle)
}
// All `XCTestObservation` methods are optional, so empty default implementations are provided
public extension XCTestObservation {
func testBundleWillStart(_ testBundle: Bundle) {}
func testSuiteWillStart(_ testSuite: XCTestSuite) {}
func testCaseWillStart(_ testCase: XCTestCase) {}
func testCase(_ testCase: XCTestCase, didFailWithDescription description: String, inFile filePath: String?, atLine lineNumber: Int) {}
func testCaseDidFinish(_ testCase: XCTestCase) {}
func testSuiteDidFinish(_ testSuite: XCTestSuite) {}
func testBundleDidFinish(_ testBundle: Bundle) {}
}
|