How to use testQuickSpecRequestingOneTestCase method of QuickSpec_SelectedTests class

Best Quick code snippet using QuickSpec_SelectedTests.testQuickSpecRequestingOneTestCase

Run Quick automation tests on LambdaTest cloud grid

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

QuickSpec_SelectedTests.swift

Source: QuickSpec_SelectedTests.swift Github

copy
1#if canImport(Darwin) && !SWIFT_PACKAGE
2
3import Nimble
4@testable import Quick
5import XCTest
6
7// The regression tests for https://github.com/Quick/Quick/issues/891
8
9class SimulateSelectedTests_TestCase: QuickSpec {
10    override class var defaultTestSuite: QuickTestSuite {
11        // XCTest doesn't call `defaultTestSuite` when running only selected tests.
12        // We simulate this behavior by not calling super.
13        return .init(name: "Selected tests")
14    }
15
16    override func spec() {
17        it("example1") { }
18        it("example2") { }
19        it("example3") { }
20    }
21}
22
23class SimulateAllTests_TestCase: QuickSpec {
24    override func spec() {
25        it("example1") { }
26        it("example2") { }
27        it("example3") { }
28    }
29}
30
31class QuickSpec_SelectedTests: XCTestCase {
32
33    func testQuickSpecTestInvocationsForAllTests() {
34        // Simulate running 'All tests'
35        let invocations = SimulateAllTests_TestCase.testInvocations
36        expect(invocations).to(haveCount(3))
37
38        let selectorNames = invocations.map { $0.selector.description }
39        expect(selectorNames).to(contain(["example1", "example2", "example3"]))
40    }
41
42    func testQuickSpecTestInvocationsForSelectedTests() {
43        // Simulate running 'Selected tests'
44        let invocations = SimulateSelectedTests_TestCase.testInvocations
45        expect(invocations).to(haveCount(3))
46
47        let selectorNames = invocations.map { $0.selector.description }
48        expect(selectorNames).to(contain(["example1", "example2", "example3"]))
49    }
50
51    func testQuickSpecRequestingNoTestCase() {
52        QuickTestSuite.reset()
53
54        let suite = XCTestSuite(forTestCaseWithName: "SimulateSelectedTests_TestCase")
55        expect(suite.tests).to(haveCount(3))
56    }
57
58    func testQuickSpecRequestingOneTestCase() {
59        QuickTestSuite.reset()
60
61        let suite = XCTestSuite(forTestCaseWithName: "SimulateSelectedTests_TestCase/example1")
62        expect(suite.tests).to(haveCount(1))
63        expect(suite.tests).to(allPass { $0.name.contains("example1") == true })
64    }
65}
66
67#endif
68
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 testQuickSpecRequestingOneTestCase code on LambdaTest Cloud Grid

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