How to use testImplicitEscapingMultipleLabeledTupleClosure_anyWildcardMatching method of ClosureParameterTests class

Best Mockingbird code snippet using ClosureParameterTests.testImplicitEscapingMultipleLabeledTupleClosure_anyWildcardMatching

Run Mockingbird automation tests on LambdaTest cloud grid

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

ClosureParameterTests.swift

Source: ClosureParameterTests.swift Github

copy
1//
2//  ClosureParameterTests.swift
3//  MockingbirdTests
4//
5//  Created by Andrew Chang on 11/29/19.
6//
7
8import XCTest
9import Mockingbird
10@testable import MockingbirdTestsHost
11
12class ClosureParameterTests: XCTestCase {
13  
14  var concreteMock: ClosureParametersProtocolMock!
15  
16  override func setUp() {
17    concreteMock = mock(ClosureParametersProtocol.self)
18  }
19  
20  // MARK: - any()
21  
22  // MARK: Non-escaping
23
24  func testTrivialClosure_anyWildcardMatching() {
25    given(concreteMock.trivialClosure(block: any())) ~> true
26    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
27      .trivialClosure(block: {}))
28    verify(concreteMock.trivialClosure(block: any())).wasCalled()
29  }
30  
31  func testTrivialReturningClosure_anyWildcardMatching() {
32    given(concreteMock.trivialReturningClosure(block: any())) ~> true
33    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
34      .trivialReturningClosure(block: { fatalError() }))
35    verify(concreteMock.trivialReturningClosure(block: any())).wasCalled()
36  }
37  
38  func testParameterizedClosure_anyWildcardMatching() {
39    given(concreteMock.parameterizedClosure(block: any())) ~> true
40    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
41      .parameterizedClosure(block: { _ in }))
42    verify(concreteMock.parameterizedClosure(block: any())).wasCalled()
43  }
44  
45  func testParameterizedReturningClosure_anyWildcardMatching() {
46    given(concreteMock.parameterizedReturningClosure(block: any())) ~> true
47    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
48      .parameterizedReturningClosure(block: { _ in fatalError() }))
49    verify(concreteMock.parameterizedReturningClosure(block: any())).wasCalled()
50  }
51  
52  // MARK: Escaping
53  
54  func testEscapingTrivialClosure_anyWildcardMatching() {
55    given(concreteMock.escapingTrivialClosure(block: any())) ~> true
56    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
57      .escapingTrivialClosure(block: {}))
58    verify(concreteMock.escapingTrivialClosure(block: any())).wasCalled()
59  }
60  
61  func testEscapingTrivialReturningClosure_anyWildcardMatching() {
62    given(concreteMock.escapingTrivialReturningClosure(block: any())) ~> true
63    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
64      .escapingTrivialReturningClosure(block: { fatalError() }))
65    verify(concreteMock.escapingTrivialReturningClosure(block: any())).wasCalled()
66  }
67  
68  func testEscapingParameterizedClosure_anyWildcardMatching() {
69    given(concreteMock.escapingParameterizedClosure(block: any())) ~> true
70    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
71      .escapingParameterizedClosure(block: { _ in }))
72    verify(concreteMock.escapingParameterizedClosure(block: any())).wasCalled()
73  }
74  
75  func testEscapingParameterizedReturningClosure_anyWildcardMatching() {
76    given(concreteMock.escapingParameterizedReturningClosure(block: any())) ~> true
77    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
78      .escapingParameterizedReturningClosure(block: { _ in fatalError() }))
79    verify(concreteMock.escapingParameterizedReturningClosure(block: any())).wasCalled()
80  }
81  
82  // MARK: Nullable
83  
84  func testImplicitEscapingTrivialClosure_anyWildcardMatching() {
85    given(concreteMock.implicitEscapingTrivialClosure(block: any())) ~> true
86    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
87      .implicitEscapingTrivialClosure(block: {}))
88    verify(concreteMock.implicitEscapingTrivialClosure(block: any())).wasCalled()
89  }
90  
91  func testImplicitEscapingTrivialReturningClosure_anyWildcardMatching() {
92    given(concreteMock.implicitEscapingTrivialReturningClosure(block: any())) ~> true
93    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
94      .implicitEscapingTrivialReturningClosure(block: { fatalError() }))
95    verify(concreteMock.implicitEscapingTrivialReturningClosure(block: any())).wasCalled()
96  }
97  
98  func testImplicitEscapingParameterizedClosure_anyWildcardMatching() {
99    given(concreteMock.implicitEscapingParameterizedClosure(block: any())) ~> true
100    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
101      .implicitEscapingParameterizedClosure(block: { _ in }))
102    verify(concreteMock.implicitEscapingParameterizedClosure(block: any())).wasCalled()
103  }
104  
105  func testImplicitEscapingParameterizedReturningClosure_anyWildcardMatching() {
106    given(concreteMock.implicitEscapingParameterizedReturningClosure(block: any())) ~> true
107    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
108      .implicitEscapingParameterizedReturningClosure(block: { _ in fatalError() }))
109    verify(concreteMock.implicitEscapingParameterizedReturningClosure(block: any())).wasCalled()
110  }
111  
112  // MARK: Wrapped
113  
114  func testWrappedClosureParameter_anyWildcardMatching() {
115    given(concreteMock.wrappedClosureParameter(block: any())) ~> true
116    XCTAssertTrue((concreteMock as ClosureParametersProtocol).wrappedClosureParameter(block: ClosureWrapper()))
117    verify(concreteMock.wrappedClosureParameter(block: any())).wasCalled()
118  }
119  
120  // MARK: Parenthesized non-escaping
121  
122  func testTrivialParenthesizedClosure_anyWildcardMatching() {
123    given(concreteMock.trivialParenthesizedClosure(block: any())) ~> true
124    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
125      .trivialParenthesizedClosure(block: {}))
126    verify(concreteMock.trivialParenthesizedClosure(block: any())).wasCalled()
127  }
128  
129  func testTrivialReturningParenthesizedClosure_anyWildcardMatching() {
130    given(concreteMock.trivialReturningParenthesizedClosure(block: any())) ~> true
131    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
132      .trivialReturningParenthesizedClosure(block: { fatalError() }))
133    verify(concreteMock.trivialReturningParenthesizedClosure(block: any())).wasCalled()
134  }
135  
136  func testParameterizedParenthesizedClosure_anyWildcardMatching() {
137    given(concreteMock.parameterizedParenthesizedClosure(block: any())) ~> true
138    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
139      .parameterizedParenthesizedClosure(block: { _ in }))
140    verify(concreteMock.parameterizedParenthesizedClosure(block: any())).wasCalled()
141  }
142  
143  func testParameterizedReturningParenthesizedClosure_anyWildcardMatching() {
144    given(concreteMock.parameterizedReturningParenthesizedClosure(block: any())) ~> true
145    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
146      .parameterizedReturningParenthesizedClosure(block: { _ in fatalError() }))
147    verify(concreteMock.parameterizedReturningParenthesizedClosure(block: any())).wasCalled()
148  }
149  
150  func testNestedParameterizedReturningParenthesizedClosure_anyWildcardMatching() {
151    given(concreteMock.nestedParameterizedReturningParenthesizedClosure(block: any())) ~> true
152    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
153      .nestedParameterizedReturningParenthesizedClosure(block: { _ in fatalError() }))
154    verify(concreteMock.nestedParameterizedReturningParenthesizedClosure(block: any())).wasCalled()
155  }
156  
157  func testNestedOptionalTrivialParenthesizedClosure_anyWildcardMatching() {
158    given(concreteMock.nestedOptionalTrivialParenthesizedClosure(block: any())) ~> true
159    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
160      .nestedOptionalTrivialParenthesizedClosure(block: {}))
161    verify(concreteMock.nestedOptionalTrivialParenthesizedClosure(block: any())).wasCalled()
162  }
163  
164  // MARK: Tuple wrapped escaping
165  
166  func testImplicitEscapingMultipleTupleClosure_anyWildcardMatching() {
167    given(concreteMock.implicitEscapingMultipleTupleClosure(block: any())) ~> true
168    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
169      .implicitEscapingMultipleTupleClosure(block: ({}, { _ in fatalError() })))
170    verify(concreteMock.implicitEscapingMultipleTupleClosure(block: any())).wasCalled()
171  }
172  
173  func testImplicitEscapingMultipleLabeledTupleClosure_anyWildcardMatching() {
174    given(concreteMock.implicitEscapingMultipleLabeledTupleClosure(block: any())) ~> true
175    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
176      .implicitEscapingMultipleLabeledTupleClosure(block: (a: {}, b: { _ in fatalError() })))
177    verify(concreteMock.implicitEscapingMultipleLabeledTupleClosure(block: any())).wasCalled()
178  }
179  
180  
181  // MARK: - notNil()
182  
183  func testImplicitEscapingTrivialClosure_notNilWildcardMatching_matchesNotNil() {
184    given(concreteMock.implicitEscapingTrivialClosure(block: notNil())) ~> true
185    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
186      .implicitEscapingTrivialClosure(block: {}))
187    verify(concreteMock.implicitEscapingTrivialClosure(block: notNil())).wasCalled()
188  }
189  
190  func testImplicitEscapingTrivialClosure_notNilWildcardMatching_doesNotMatchNil() {
191    given(concreteMock.implicitEscapingTrivialClosure(block: any())) ~> true
192    given(concreteMock.implicitEscapingTrivialClosure(block: notNil())) ~> false
193    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
194      .implicitEscapingTrivialClosure(block: nil))
195    verify(concreteMock.implicitEscapingTrivialClosure(block: any())).wasCalled()
196    verify(concreteMock.implicitEscapingTrivialClosure(block: notNil())).wasNeverCalled()
197  }
198  
199  func testImplicitEscapingTrivialReturningClosure_notNilWildcardMatching_matchesNotNil() {
200    given(concreteMock.implicitEscapingTrivialReturningClosure(block: notNil())) ~> true
201    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
202      .implicitEscapingTrivialReturningClosure(block: { fatalError() }))
203    verify(concreteMock.implicitEscapingTrivialReturningClosure(block: notNil())).wasCalled()
204  }
205  
206  func testImplicitEscapingTrivialReturningClosure_notNilWildcardMatching_doesNotMatchNil() {
207    given(concreteMock.implicitEscapingTrivialReturningClosure(block: any())) ~> true
208    given(concreteMock.implicitEscapingTrivialReturningClosure(block: notNil())) ~> false
209    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
210      .implicitEscapingTrivialReturningClosure(block: nil))
211    verify(concreteMock.implicitEscapingTrivialReturningClosure(block: any())).wasCalled()
212    verify(concreteMock.implicitEscapingTrivialReturningClosure(block: notNil())).wasNeverCalled()
213  }
214  
215  func testImplicitEscapingParameterizedClosure_notNilWildcardMatching_matchesNotNil() {
216    given(concreteMock.implicitEscapingParameterizedClosure(block: notNil())) ~> true
217    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
218      .implicitEscapingParameterizedClosure(block: { _ in }))
219    verify(concreteMock.implicitEscapingParameterizedClosure(block: notNil())).wasCalled()
220  }
221  
222  func testImplicitEscapingParameterizedClosure_notNilWildcardMatching_doesNotMatchNil() {
223    given(concreteMock.implicitEscapingParameterizedClosure(block: any())) ~> true
224    given(concreteMock.implicitEscapingParameterizedClosure(block: notNil())) ~> false
225    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
226      .implicitEscapingParameterizedClosure(block: nil))
227    verify(concreteMock.implicitEscapingParameterizedClosure(block: any())).wasCalled()
228    verify(concreteMock.implicitEscapingParameterizedClosure(block: notNil())).wasNeverCalled()
229  }
230  
231  func testImplicitEscapingParameterizedReturningClosure_notNilWildcardMatching_matchesNotNil() {
232    given(concreteMock.implicitEscapingParameterizedReturningClosure(block: notNil())) ~> true
233    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
234      .implicitEscapingParameterizedReturningClosure(block: { _ in fatalError() }))
235    verify(concreteMock.implicitEscapingParameterizedReturningClosure(block: notNil())).wasCalled()
236  }
237  
238  func testImplicitEscapingParameterizedReturningClosure_notNilWildcardMatching_doesNotMatchNil() {
239    given(concreteMock.implicitEscapingParameterizedReturningClosure(block: any())) ~> true
240    given(concreteMock.implicitEscapingParameterizedReturningClosure(block: notNil())) ~> false
241    XCTAssertTrue((concreteMock as ClosureParametersProtocol)
242      .implicitEscapingParameterizedReturningClosure(block: nil))
243    verify(concreteMock.implicitEscapingParameterizedReturningClosure(block: any())).wasCalled()
244    verify(concreteMock.implicitEscapingParameterizedReturningClosure(block: notNil())).wasNeverCalled()
245  }
246}
247
248
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 ClosureParameterTests

Trigger testImplicitEscapingMultipleLabeledTupleClosure_anyWildcardMatching code on LambdaTest Cloud Grid

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