How to use spec method of FunctionalTests_FocusedSpec_Behavior class

Best Quick code snippet using FunctionalTests_FocusedSpec_Behavior.spec

Run Quick automation tests on LambdaTest cloud grid

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

FocusedTests.swift

Source: FocusedTests.swift Github

copy
1import Quick
2import Nimble
3import XCTest
4
5class FunctionalTests_FocusedSpec_SharedExamplesConfiguration: QuickConfiguration {
6    override class func configure(_ configuration: Configuration) {
7        sharedExamples("two passing shared examples") {
8            it("has an example that passes (4)") {}
9            it("has another example that passes (5)") {}
10        }
11    }
12}
13
14class FunctionalTests_FocusedSpec_Behavior: Behavior<Void> {
15    override static func spec(_ aContext: @escaping () -> Void) {
16        it("pass once") { expect(true).to(beTruthy()) }
17        it("pass twice") { expect(true).to(beTruthy()) }
18        it("pass three times") { expect(true).to(beTruthy()) }
19    }
20}
21
22// The following `QuickSpec`s will be run in a same test suite with other specs
23// on SwiftPM. We must avoid that the focused flags below affect other specs, so
24// the examples of the two specs must be gathered lastly. That is the reason why
25// the two specs have underscore prefix (and are listed at the bottom of `QCKMain`s
26// `specs` array).
27
28class _FunctionalTests_FocusedSpec_Focused: QuickSpec {
29    override func spec() {
30        it("has an unfocused example that fails, but is never run") { fail() }
31        fit("has a focused example that passes (1)") {}
32
33        fdescribe("a focused example group") {
34            it("has an example that is not focused, but will be run, and passes (2)") {}
35            fit("has a focused example that passes (3)") {}
36        }
37
38        fitBehavesLike("two passing shared examples")
39        fitBehavesLike(FunctionalTests_FocusedSpec_Behavior.self) { () -> Void in }
40    }
41}
42
43class _FunctionalTests_FocusedSpec_Unfocused: QuickSpec {
44    override func spec() {
45        it("has an unfocused example that fails, but is never run") { fail() }
46
47        describe("an unfocused example group that is never run") {
48            beforeEach { assert(false) }
49            it("has an example that fails, but is never run") { fail() }
50        }
51    }
52}
53
54final class FocusedTests: XCTestCase, XCTestCaseProvider {
55    static var allTests: [(String, (FocusedTests) -> () throws -> Void)] {
56        return [
57            ("testOnlyFocusedExamplesAreExecuted", testOnlyFocusedExamplesAreExecuted)
58        ]
59    }
60
61    func testOnlyFocusedExamplesAreExecuted() {
62        let result = qck_runSpecs([
63            _FunctionalTests_FocusedSpec_Focused.self,
64            _FunctionalTests_FocusedSpec_Unfocused.self
65        ])
66        XCTAssertEqual(result?.executionCount, 8)
67    }
68}
69
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

Most used method in FunctionalTests_FocusedSpec_Behavior

Trigger spec code on LambdaTest Cloud Grid

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