How to use testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample method of SharedExamples_BeforeEachTests class

Best Quick code snippet using SharedExamples_BeforeEachTests.testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample

Run Quick automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

SharedExamples+BeforeEachTests.swift

Source: SharedExamples+BeforeEachTests.swift Github

copy
1import XCTest
2import Quick
3import Nimble
4
5var specBeforeEachExecutedCount = 0
6var sharedExamplesBeforeEachExecutedCount = 0
7
8class FunctionalTests_SharedExamples_BeforeEachTests_SharedExamples: QuickConfiguration {
9    override class func configure(_ configuration: Configuration) {
10        sharedExamples("a group of three shared examples with a beforeEach") {
11            beforeEach { sharedExamplesBeforeEachExecutedCount += 1 }
12            it("passes once") {}
13            it("passes twice") {}
14            it("passes three times") {}
15        }
16    }
17}
18
19class FunctionalTests_SharedExamples_BeforeEachSpec: QuickSpec {
20    override func spec() {
21        beforeEach { specBeforeEachExecutedCount += 1 }
22        it("executes the spec beforeEach once") {}
23        itBehavesLike("a group of three shared examples with a beforeEach")
24    }
25}
26
27final class SharedExamples_BeforeEachTests: XCTestCase, XCTestCaseProvider {
28    static var allTests: [(String, (SharedExamples_BeforeEachTests) -> () throws -> Void)] {
29        return [
30            ("testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample", testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample),
31            ("testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample", testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample)
32        ]
33    }
34
35    func testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample() {
36        specBeforeEachExecutedCount = 0
37
38        qck_runSpec(FunctionalTests_SharedExamples_BeforeEachSpec.self)
39        XCTAssertEqual(specBeforeEachExecutedCount, 4)
40    }
41
42    func testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample() {
43        sharedExamplesBeforeEachExecutedCount = 0
44
45        qck_runSpec(FunctionalTests_SharedExamples_BeforeEachSpec.self)
46        XCTAssertEqual(sharedExamplesBeforeEachExecutedCount, 3)
47    }
48}
49
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample code on LambdaTest Cloud Grid

Execute automation tests with testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)