How to use testAGroupOfThreeSharedExamplesExecutesThreeExamples method of SharedExamplesTests class

Best Quick code snippet using SharedExamplesTests.testAGroupOfThreeSharedExamplesExecutesThreeExamples

Run Quick automation tests on LambdaTest cloud grid

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

SharedExamplesTests.swift

Source: SharedExamplesTests.swift Github

copy
1import Foundation
2import XCTest
3import Quick
4import Nimble
5
6class FunctionalTests_SharedExamples_Spec: QuickSpec {
7    override func spec() {
8        itBehavesLike("a group of three shared examples")
9    }
10}
11
12class FunctionalTests_SharedExamples_ContextSpec: QuickSpec {
13    override func spec() {
14        itBehavesLike("shared examples that take a context") { ["callsite": "SharedExamplesSpec"] }
15    }
16}
17
18#if _runtime(_ObjC) && !SWIFT_PACKAGE
19class FunctionalTests_SharedExamples_ErrorSpec: QuickSpec {
20    override func spec() {
21        describe("error handling when misusing ordering") {
22            it("should throw an exception when including itBehavesLike in it block") {
23                expect {
24                    itBehavesLike("a group of three shared examples")
25                    }.to(raiseException { (exception: NSException) in
26                        expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
27                        expect(exception.reason).to(equal("'itBehavesLike' cannot be used inside 'it', 'itBehavesLike' may only be used inside 'context' or 'describe'. "))
28                        })
29            }
30        }
31    }
32}
33#endif
34
35// Shared examples are defined in QuickTests/Fixtures
36final class SharedExamplesTests: XCTestCase, XCTestCaseProvider {
37    static var allTests: [(String, (SharedExamplesTests) -> () throws -> Void)] {
38        return [
39            ("testAGroupOfThreeSharedExamplesExecutesThreeExamples", testAGroupOfThreeSharedExamplesExecutesThreeExamples),
40            ("testSharedExamplesWithContextPassContextToExamples", testSharedExamplesWithContextPassContextToExamples),
41        ]
42    }
43
44    func testAGroupOfThreeSharedExamplesExecutesThreeExamples() {
45        let result = qck_runSpec(FunctionalTests_SharedExamples_Spec.self)
46        XCTAssert(result!.hasSucceeded)
47        XCTAssertEqual(result!.executionCount, 3 as UInt)
48    }
49
50    func testSharedExamplesWithContextPassContextToExamples() {
51        let result = qck_runSpec(FunctionalTests_SharedExamples_ContextSpec.self)
52        XCTAssert(result!.hasSucceeded)
53    }
54}
55
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 testAGroupOfThreeSharedExamplesExecutesThreeExamples code on LambdaTest Cloud Grid

Execute automation tests with testAGroupOfThreeSharedExamplesExecutesThreeExamples 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)