How to use childParameterizedInstanceMethod method of func class

Best Mockingbird code snippet using func.childParameterizedInstanceMethod

StubbingTests.swift

Source:StubbingTests.swift Github

copy

Full Screen

...65    verify(childProtocol.childTrivialInstanceMethod()).wasCalled()66  }67  68  func testStubParameterizedMethodWithWildcardMatcher_onClassMock() {69    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> true70    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))71    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()72    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()73  }74  func testStubParameterizedMethodWithWildcardMatcher_onProtocolMock() {75    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())) ~> true76    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))77    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()78    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()79  }80  81  func testStubParameterizedMethodWithWildcardMatcher_onClassMock_explicitSyntax() {82    given(child.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)83    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))84    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()85    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()86  }87  func testStubParameterizedMethodWithWildcardMatcher_onProtocolMock_explicitSyntax() {88    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)89    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))90    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()91    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()92  }93  94  func testStubParameterizedMethodWithExactValue_onClassMock() {95    given(child.childParameterizedInstanceMethod(param1: true, 1)) ~> true96    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))97    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()98  }99  func testStubParameterizedMethodWithExactValue_onProtocolMock() {100    given(childProtocol.childParameterizedInstanceMethod(param1: true, 1)) ~> true101    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))102    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()103  }104  105  func testStubParameterizedMethodWithExactValue_onClassMock_explicitSyntax() {106    given(child.childParameterizedInstanceMethod(param1: true, 1)).willReturn(true)107    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))108    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()109  }110  func testStubParameterizedMethodWithExactValue_onProtocolMock_explicitSyntax() {111    given(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).willReturn(true)112    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))113    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()114  }115  116  // MARK: Non-matching117  118  func testStubParameterizedMethodWithWildcardMatcher_doesNotMatch_onClassMock() {119    shouldFail {120      given(self.child.childParameterizedInstanceMethod(param1: any(), 1)) ~> true121      XCTAssertTrue(self.childInstance.childParameterizedInstanceMethod(param1: true, 2))122    }123  }124  func testStubParameterizedMethodWithWildcardMatcher_doesNotMatch_onProtocolMock() {125    shouldFail {126      given(self.childProtocol.childParameterizedInstanceMethod(param1: any(), 1)) ~> true127      XCTAssertTrue(self.childProtocolInstance.childParameterizedInstanceMethod(param1: true, 2))128    }129  }130  131  func testStubParameterizedMethodWithWildcardMatcher_doesNotMatch_onClassMock_explicitSyntax() {132    shouldFail {133      given(self.child.childParameterizedInstanceMethod(param1: any(), 1)).willReturn(true)134      XCTAssertTrue(self.childInstance.childParameterizedInstanceMethod(param1: true, 2))135    }136  }137  func testStubParameterizedMethodWithWildcardMatcher_doesNotMatch_onProtocolMock_explicitSyntax() {138    shouldFail {139      given(self.childProtocol.childParameterizedInstanceMethod(param1: any(), 1)).willReturn(true)140      XCTAssertTrue(self.childProtocolInstance.childParameterizedInstanceMethod(param1: true, 2))141    }142  }143  144  func testStubParameterizedMethodWithExactValue_doesNotMatch_onClassMock() {145    shouldFail {146      given(self.child.childParameterizedInstanceMethod(param1: true, 1)) ~> true147      XCTAssertTrue(self.childInstance.childParameterizedInstanceMethod(param1: false, 1))148    }149  }150  func testStubParameterizedMethodWithExactValue_doesNotMatch_onProtocolMock() {151    shouldFail {152      given(self.childProtocol.childParameterizedInstanceMethod(param1: true, 1)) ~> true153      XCTAssertTrue(self.childProtocolInstance.childParameterizedInstanceMethod(param1: false, 1))154    }155  }156  157  func testStubParameterizedMethodWithExactValue_doesNotMatch_onClassMock_explicitSyntax() {158    shouldFail {159      given(self.child.childParameterizedInstanceMethod(param1: true, 1)).willReturn(true)160      XCTAssertTrue(self.childInstance.childParameterizedInstanceMethod(param1: false, 1))161    }162  }163  func testStubParameterizedMethodWithExactValue_doesNotMatch_onProtocolMock_explicitSyntax() {164    shouldFail {165      given(self.childProtocol.childParameterizedInstanceMethod(param1: true, 1)).willReturn(true)166      XCTAssertTrue(self.childProtocolInstance.childParameterizedInstanceMethod(param1: false, 1))167    }168  }169  170  // MARK: Value consistency171  172  func testStubReturnValueReturnsSameValue_onClassMock() {173    given(child.getChildComputedInstanceVariable()) ~> true174    XCTAssertTrue(childInstance.childComputedInstanceVariable)175    XCTAssertTrue(childInstance.childComputedInstanceVariable)176    XCTAssertTrue(childInstance.childComputedInstanceVariable)177    verify(child.getChildComputedInstanceVariable()).wasCalled(exactly(3))178  }179  func testStubReturnValueReturnsSameValue_onProtocolMock() {180    given(childProtocol.getChildInstanceVariable()) ~> true181    XCTAssertTrue(childProtocolInstance.childInstanceVariable)182    XCTAssertTrue(childProtocolInstance.childInstanceVariable)183    XCTAssertTrue(childProtocolInstance.childInstanceVariable)184    verify(childProtocol.getChildInstanceVariable()).wasCalled(exactly(3))185  }186  187  func testStubReturnValueReturnsSameValue_onClassMock_explicitSyntax() {188    given(child.getChildComputedInstanceVariable()).willReturn(true)189    XCTAssertTrue(childInstance.childComputedInstanceVariable)190    XCTAssertTrue(childInstance.childComputedInstanceVariable)191    XCTAssertTrue(childInstance.childComputedInstanceVariable)192    verify(child.getChildComputedInstanceVariable()).wasCalled(exactly(3))193  }194  func testStubReturnValueReturnsSameValue_onProtocolMock_explicitSyntax() {195    given(childProtocol.getChildInstanceVariable()).willReturn(true)196    XCTAssertTrue(childProtocolInstance.childInstanceVariable)197    XCTAssertTrue(childProtocolInstance.childInstanceVariable)198    XCTAssertTrue(childProtocolInstance.childInstanceVariable)199    verify(childProtocol.getChildInstanceVariable()).wasCalled(exactly(3))200  }201  202  // MARK: Precedence203  204  func testStubParameterizedMethodOverridesPrevious_onClassMock() {205    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> true206    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> false207    XCTAssertFalse(childInstance.childParameterizedInstanceMethod(param1: true, 1))208    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()209    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()210  }211  func testStubParameterizedMethodOverridesPrevious_onProtocolMock() {212    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())) ~> true213    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())) ~> false214    XCTAssertFalse(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))215    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()216    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()217  }218  219  func testStubParameterizedMethodOverridesPrevious_onClassMock_explicitSyntax() {220    given(child.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)221    given(child.childParameterizedInstanceMethod(param1: any(), any())).willReturn(false)222    XCTAssertFalse(childInstance.childParameterizedInstanceMethod(param1: true, 1))223    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()224    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()225  }226  func testStubParameterizedMethodOverridesPrevious_onProtocolMock_explicitSyntax() {227    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)228    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).willReturn(false)229    XCTAssertFalse(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))230    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()231    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()232  }233  234  func testStubParameterizedMethodIgnoresNonMatching_onClassMock() {235    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> true236    given(child.childParameterizedInstanceMethod(param1: any(), 100)) ~> false237    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))238    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()239    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()240  }241  func testStubParameterizedMethodIgnoresNonMatching_onProtocolMock() {242    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())) ~> true243    given(childProtocol.childParameterizedInstanceMethod(param1: any(), 100)) ~> false244    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))245    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()246    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()247  }248  249  func testStubParameterizedMethodIgnoresNonMatching_onClassMock_explicitSyntax() {250    given(child.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)251    given(child.childParameterizedInstanceMethod(param1: any(), 100)).willReturn(false)252    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))253    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()254    verify(child.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()255  }256  func testStubParameterizedMethodIgnoresNonMatching_onProtocolMock_explicitSyntax() {257    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).willReturn(true)258    given(childProtocol.childParameterizedInstanceMethod(param1: any(), 100)).willReturn(false)259    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))260    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()261    verify(childProtocol.childParameterizedInstanceMethod(param1: true, 1)).wasCalled()262  }263  264  // MARK: Clearing stubs265  266  func testClearStubs_onClassMock() {267    shouldFail {268      given(self.child.getChildStoredInstanceVariable()) ~> true269      clearStubs(on: self.child)270      XCTAssertTrue(self.child.childStoredInstanceVariable)271    }272  }273  func testClearStubs_onProtocolMock() {274    shouldFail {275      given(self.childProtocol.getChildInstanceVariable()) ~> true276      clearStubs(on: self.childProtocol)277      XCTAssertTrue(self.child.childComputedInstanceVariable)278    }279  }280  281  func testClearStubs_onClassMock_explicitSyntax() {282    shouldFail {283      given(self.child.getChildStoredInstanceVariable()).willReturn(true)284      clearStubs(on: self.child)285      XCTAssertTrue(self.child.childStoredInstanceVariable)286    }287  }288  func testClearStubs_onProtocolMock_explicitSyntax() {289    shouldFail {290      given(self.childProtocol.getChildInstanceVariable()).willReturn(true)291      clearStubs(on: self.childProtocol)292      XCTAssertTrue(self.child.childComputedInstanceVariable)293    }294  }295  296  // MARK: Closure implementation stubs297  298  func testStubParameterizedMethod_onClassMock_withExplicitlyTypedClosure() {299    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> {300      (param1: Bool, param2: Int) -> Bool in301      return param1 && param2 == 1302    }303    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))304    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()305  }306  func testStubParameterizedMethod_onProtocolMock_withExplicitlyTypedClosure() {307    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any())) ~> {308      (param1: Bool, param2: Int) -> Bool in309      return param1 && param2 == 1310    }311    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))312    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()313  }314  315  func testStubParameterizedMethod_onClassMock_withImplicitlyTypedClosure() {316    given(child.childParameterizedInstanceMethod(param1: any(), any()))317      ~> { $0 && $1 == 1 }318    XCTAssertTrue(childInstance.childParameterizedInstanceMethod(param1: true, 1))319    verify(child.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()320  }321  func testStubParameterizedMethod_onProtocolMock_withImplicitlyTypedClosure() {322    given(childProtocol.childParameterizedInstanceMethod(param1: any(), any()))323      ~> { $0 && $1 == 1 }324    XCTAssertTrue(childProtocolInstance.childParameterizedInstanceMethod(param1: true, 1))325    verify(childProtocol.childParameterizedInstanceMethod(param1: any(), any())).wasCalled()326  }327  328  func testStubTrivialMethod_onClassMock_withExplicitClosure() {329    given(child.childTrivialInstanceMethod()) ~> {}330    childInstance.childTrivialInstanceMethod()331    verify(child.childTrivialInstanceMethod()).wasCalled()332  }333  func testStubTrivialMethod_onProtocolMock_withExplicitClosure() {334    given(childProtocol.childTrivialInstanceMethod()) ~> {}335    childProtocolInstance.childTrivialInstanceMethod()336    verify(childProtocol.childTrivialInstanceMethod()).wasCalled()337  }338  339  func testStubNonParameterizedReturningMethod_onClassMock_withExplicitClosure() {...

Full Screen

Full Screen

XFailOrderedVerificationTests.swift

Source:XFailOrderedVerificationTests.swift Github

copy

Full Screen

...12  var child: ChildMock!13  14  override func setUp() {15    child = mock(Child.self)16    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> true17  }18  19  // MARK: - Relative ordering20  21  func testRelativeOrderVerification_trivialComparison() {22    let child: ChildMock = self.child23    shouldFail {24      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))25      (child as Child).childTrivialInstanceMethod()26      27      inOrder {28        verify(child.childTrivialInstanceMethod()).wasCalled()29        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()30      }31    }32  }33  34  func testRelativeOrderVerification_trivialComparisonWithPaddingBefore() {35    let child: ChildMock = self.child36    shouldFail {37      // Padding38      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))39      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))40      41      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))42      (child as Child).childTrivialInstanceMethod()43      44      inOrder {45        verify(child.childTrivialInstanceMethod()).wasCalled()46        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()47      }48    }49  }50  51  func testRelativeOrderVerification_trivialComparisonWithPaddingBetween() {52    let child: ChildMock = self.child53    shouldFail {54      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))55      56      // Padding57      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))58      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))59      60      (child as Child).childTrivialInstanceMethod()61      62      inOrder {63        verify(child.childTrivialInstanceMethod()).wasCalled()64        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()65      }66    }67  }68  69  func testRelativeOrderVerification_trivialComparisonWithPaddingAfter() {70    let child: ChildMock = self.child71    shouldFail {72      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))73      (child as Child).childTrivialInstanceMethod()74      75      // Padding76      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))77      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))78      79      inOrder {80        verify(child.childTrivialInstanceMethod()).wasCalled()81        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()82      }83    }84  }85  86  func testRelativeOrderVerification_multipleSameInvocationsBefore() {87    let child: ChildMock = self.child88    shouldFail {89      (child as Child).childTrivialInstanceMethod()90      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))91      (child as Child).childTrivialInstanceMethod()92      93      inOrder {94        verify(child.childTrivialInstanceMethod()).wasCalled()95        verify(child.childTrivialInstanceMethod()).wasCalled()96        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()97        verify(child.childTrivialInstanceMethod()).wasCalled()98      }99    }100  }101  102  func testRelativeOrderVerification_multipleSameInvocationsAfter() {103    let child: ChildMock = self.child104    shouldFail {105      (child as Child).childTrivialInstanceMethod()106      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))107      (child as Child).childTrivialInstanceMethod()108      109      inOrder {110        verify(child.childTrivialInstanceMethod()).wasCalled()111        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()112        verify(child.childTrivialInstanceMethod()).wasCalled()113        verify(child.childTrivialInstanceMethod()).wasCalled()114      }115    }116  }117  118  func testRelativeOrderVerification_handlesExactCountMatcher() {119    let child: ChildMock = self.child120    shouldFail {121      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))122      (child as Child).childTrivialInstanceMethod()123      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))124      125      inOrder {126        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()127        verify(child.childTrivialInstanceMethod()).wasCalled(twice)128        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()129      }130    }131  }132  133  func testRelativeOrderVerification_handlesAtLeastCountMatcher() {134    let child: ChildMock = self.child135    shouldFail {136      (child as Child).childTrivialInstanceMethod()137      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))138      139      inOrder {140        verify(child.childTrivialInstanceMethod()).wasCalled(atLeast(twice))141        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()142      }143    }144  }145  146  func testRelativeOrderVerification_handlesAtLeastCountMatcher_validPaddingBefore() {147    let child: ChildMock = self.child148    shouldFail {149      // Padding150      (child as Child).childTrivialInstanceMethod()151      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))152      153      (child as Child).childTrivialInstanceMethod()154      (child as Child).childTrivialInstanceMethod()155      (child as Child).childTrivialInstanceMethod()156      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))157      158      inOrder {159        verify(child.childTrivialInstanceMethod()).wasCalled(atLeast(twice))160        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()161      }162    }163  }164  165  func testRelativeOrderVerification_handlesAtLeastCountMatcher_validPaddingBetween() {166    let child: ChildMock = self.child167    shouldFail {168      (child as Child).childTrivialInstanceMethod()169      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))170      (child as Child).childTrivialInstanceMethod()171      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))172      173      inOrder {174        verify(child.childTrivialInstanceMethod()).wasCalled(atLeast(twice))175        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()176      }177    }178  }179  180  func testRelativeOrderVerification_handlesAtMostCountMatcher() {181    let child: ChildMock = self.child182    shouldFail {183      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))184      (child as Child).childTrivialInstanceMethod()185      (child as Child).childTrivialInstanceMethod()186      (child as Child).childTrivialInstanceMethod()187      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))188      189      inOrder {190        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()191        verify(child.childTrivialInstanceMethod()).wasCalled(atMost(twice))192        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()193      }194    }195  }196  197  func testRelativeOrderVerification_handlesAtMostCountMatcher_validPaddingBefore() {198    let child: ChildMock = self.child199    shouldFail {200      // Padding201      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))202      (child as Child).childTrivialInstanceMethod()203      (child as Child).childTrivialInstanceMethod()204      (child as Child).childTrivialInstanceMethod()205      206      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))207      (child as Child).childTrivialInstanceMethod()208      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))209      210      inOrder {211        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()212        verify(child.childTrivialInstanceMethod()).wasCalled(atMost(twice))213        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()214      }215    }216  }217  218  219  // MARK: - Only consecutive invocations220  221  func testOnlyConsecutiveInvocations_paddingBetween() {222    let child: ChildMock = self.child223    shouldFail {224      (child as Child).childTrivialInstanceMethod()225      226      // Padding227      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))228      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))229      230      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))231      232      inOrder(with: .onlyConsecutiveInvocations) {233        verify(child.childTrivialInstanceMethod()).wasCalled()234        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()235      }236    }237  }238  239  240  // MARK: - No invocations before241  242  func testNoInvocationsBefore_arbitraryPaddingBefore() {243    let child: ChildMock = self.child244    shouldFail {245      // Padding246      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))247      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))248      249      (child as Child).childTrivialInstanceMethod()250      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))251      252      inOrder(with: .noInvocationsBefore) {253        verify(child.childTrivialInstanceMethod()).wasCalled()254        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()255      }256    }257  }258  259  func testNoInvocationsBefore_validPaddingBefore() {260    let child: ChildMock = self.child261    shouldFail {262    // Padding263      (child as Child).childTrivialInstanceMethod()264      265      (child as Child).childTrivialInstanceMethod()266      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))267      268      inOrder(with: .noInvocationsBefore) {269        verify(child.childTrivialInstanceMethod()).wasCalled()270        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()271      }272    }273  }274  275  276  // MARK: - No invocations after277  278  func testNoInvocationsBefore_arbitraryPaddingAfter() {279    let child: ChildMock = self.child280    shouldFail {281      (child as Child).childTrivialInstanceMethod()282      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))283      284      // Padding285      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))286      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))287      288      inOrder(with: .noInvocationsAfter) {289        verify(child.childTrivialInstanceMethod()).wasCalled()290        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()291      }292    }293  }294  295  func testNoInvocationsBefore_validPaddingAfter() {296    let child: ChildMock = self.child297    shouldFail {298      (child as Child).childTrivialInstanceMethod()299      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))300      301      // Padding302      XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))303      304      inOrder(with: .noInvocationsAfter) {305        verify(child.childTrivialInstanceMethod()).wasCalled()306        verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()307      }308    }309  }310}...

Full Screen

Full Screen

OrderedVerificationTests.swift

Source:OrderedVerificationTests.swift Github

copy

Full Screen

...12  var child: ChildMock!13  14  override func setUp() {15    child = mock(Child.self)16    given(child.childParameterizedInstanceMethod(param1: any(), any())) ~> true17  }18  19  // MARK: - Relative ordering20  21  func testRelativeOrderVerification_trivialComparison() {22    (child as Child).childTrivialInstanceMethod()23    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))24    25    inOrder {26      verify(child.childTrivialInstanceMethod()).wasCalled()27      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()28    }29  }30  31  func testRelativeOrderVerification_trivialComparisonWithPaddingBefore() {32    // Padding33    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))34    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))35    36    (child as Child).childTrivialInstanceMethod()37    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))38    39    inOrder {40      verify(child.childTrivialInstanceMethod()).wasCalled()41      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()42    }43  }44  45  func testRelativeOrderVerification_trivialComparisonWithPaddingBetween() {46    (child as Child).childTrivialInstanceMethod()47    48    // Padding49    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))50    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))51    52    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))53    54    inOrder {55      verify(child.childTrivialInstanceMethod()).wasCalled()56      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()57    }58  }59  60  func testRelativeOrderVerification_trivialComparisonWithPaddingAfter() {61    (child as Child).childTrivialInstanceMethod()62    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))63    64    // Padding65    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))66    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))67    68    inOrder {69      verify(child.childTrivialInstanceMethod()).wasCalled()70      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()71    }72  }73  74  func testRelativeOrderVerification_multipleSameInvocationsBefore() {75    (child as Child).childTrivialInstanceMethod()76    (child as Child).childTrivialInstanceMethod()77    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))78    (child as Child).childTrivialInstanceMethod()79    80    inOrder {81      verify(child.childTrivialInstanceMethod()).wasCalled()82      verify(child.childTrivialInstanceMethod()).wasCalled()83      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()84      verify(child.childTrivialInstanceMethod()).wasCalled()85    }86  }87  88  func testRelativeOrderVerification_multipleSameInvocationsAfter() {89    (child as Child).childTrivialInstanceMethod()90    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))91    (child as Child).childTrivialInstanceMethod()92    (child as Child).childTrivialInstanceMethod()93    94    inOrder {95      verify(child.childTrivialInstanceMethod()).wasCalled()96      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()97      verify(child.childTrivialInstanceMethod()).wasCalled()98      verify(child.childTrivialInstanceMethod()).wasCalled()99    }100  }101  102  func testRelativeOrderVerification_handlesExactCountMatcher() {103    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))104    (child as Child).childTrivialInstanceMethod()105    (child as Child).childTrivialInstanceMethod()106    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))107    108    inOrder {109      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()110      verify(child.childTrivialInstanceMethod()).wasCalled(twice)111      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()112    }113  }114  115  func testRelativeOrderVerification_handlesAtLeastCountMatcher() {116    (child as Child).childTrivialInstanceMethod()117    (child as Child).childTrivialInstanceMethod()118    (child as Child).childTrivialInstanceMethod()119    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))120    121    inOrder {122      verify(child.childTrivialInstanceMethod()).wasCalled(atLeast(twice))123      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()124    }125  }126  127  func testRelativeOrderVerification_handlesAtMostCountMatcher() {128    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))129    (child as Child).childTrivialInstanceMethod()130    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))131    132    inOrder {133      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()134      verify(child.childTrivialInstanceMethod()).wasCalled(atMost(twice))135      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()136    }137  }138  139  func testRelativeOrderVerification_handlesCompoundCountMatcher() {140    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))141    (child as Child).childTrivialInstanceMethod()142    (child as Child).childTrivialInstanceMethod()143    (child as Child).childTrivialInstanceMethod()144    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))145    146    inOrder {147      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()148      verify(child.childTrivialInstanceMethod()).wasCalled(not(once).and(not(twice)))149      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()150    }151  }152  153  154  // MARK: - Only consecutive invocations155  156  func testOnlyConsecutiveInvocations() {157    (child as Child).childTrivialInstanceMethod()158    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))159    160    inOrder(with: .onlyConsecutiveInvocations) {161      verify(child.childTrivialInstanceMethod()).wasCalled()162      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()163    }164  }165  166  func testOnlyConsecutiveInvocations_paddingBefore() {167    // Padding168    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))169    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))170    171    (child as Child).childTrivialInstanceMethod()172    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))173    174    inOrder(with: .onlyConsecutiveInvocations) {175      verify(child.childTrivialInstanceMethod()).wasCalled()176      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()177    }178  }179  180  func testOnlyConsecutiveInvocations_paddingAfter() {181    (child as Child).childTrivialInstanceMethod()182    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: true, 42))183    184    // Padding185    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))186    XCTAssertTrue((child as Child).childParameterizedInstanceMethod(param1: false, 1337))187    188    inOrder(with: .onlyConsecutiveInvocations) {189      verify(child.childTrivialInstanceMethod()).wasCalled()190      verify(child.childParameterizedInstanceMethod(param1: true, 42)).wasCalled()191    }192  }193}...

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1let funcInstance = Func()2funcInstance.childParameterizedInstanceMethod(1, 2)3let funcInstance = Func()4funcInstance.childParameterizedInstanceMethod(1, 2)5let funcInstance = Func()6funcInstance.childParameterizedInstanceMethod(1, 2)7let funcInstance = Func()8funcInstance.childParameterizedInstanceMethod(1, 2)9let funcInstance = Func()10funcInstance.childParameterizedInstanceMethod(1, 2)11let funcInstance = Func()12funcInstance.childParameterizedInstanceMethod(1, 2)13let funcInstance = Func()14funcInstance.childParameterizedInstanceMethod(1, 2)15let funcInstance = Func()16funcInstance.childParameterizedInstanceMethod(1, 2)17let funcInstance = Func()18funcInstance.childParameterizedInstanceMethod(1, 2)19let funcInstance = Func()20funcInstance.childParameterizedInstanceMethod(1, 2)21let funcInstance = Func()22funcInstance.childParameterizedInstanceMethod(1, 2)23let funcInstance = Func()24funcInstance.childParameterizedInstanceMethod(1, 2)25let funcInstance = Func()26funcInstance.childParameterizedInstanceMethod(1, 2

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1let funcClassInstance = FuncClass()2funcClassInstance.childParameterizedInstanceMethod(5)3let funcClassInstance = FuncClass()4funcClassInstance.childParameterizedInstanceMethod(5)5let funcClassInstance = FuncClass()6funcClassInstance.childParameterizedInstanceMethod(5)7let funcClassInstance = FuncClass()8funcClassInstance.childParameterizedInstanceMethod(5)9let funcClassInstance = FuncClass()10funcClassInstance.childParameterizedInstanceMethod(5)11let funcClassInstance = FuncClass()12funcClassInstance.childParameterizedInstanceMethod(5)13let funcClassInstance = FuncClass()14funcClassInstance.childParameterizedInstanceMethod(5)15let funcClassInstance = FuncClass()16funcClassInstance.childParameterizedInstanceMethod(5)17let funcClassInstance = FuncClass()18funcClassInstance.childParameterizedInstanceMethod(5)19let funcClassInstance = FuncClass()20funcClassInstance.childParameterizedInstanceMethod(5)21let funcClassInstance = FuncClass()22funcClassInstance.childParameterizedInstanceMethod(5)23let funcClassInstance = FuncClass()24funcClassInstance.childParameterizedInstanceMethod(5)25let funcClassInstance = FuncClass()26funcClassInstance.childParameterizedInstanceMethod(5

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1func childParameterizedInstanceMethod() {2    let child = Child()3    child.parameterizedInstanceMethod(10)4}5func childParameterizedInstanceMethod() {6    let child = Child()7    child.parameterizedInstanceMethod(10)8}9func childParameterizedInstanceMethod() {10    let child = Child()11    child.parameterizedInstanceMethod(10)12}13func childParameterizedInstanceMethod() {14    let child = Child()15    child.parameterizedInstanceMethod(10)16}17func childParameterizedInstanceMethod() {18    let child = Child()19    child.parameterizedInstanceMethod(10)20}21func childParameterizedInstanceMethod() {22    let child = Child()23    child.parameterizedInstanceMethod(10)24}25func childParameterizedInstanceMethod() {26    let child = Child()27    child.parameterizedInstanceMethod(10)28}29func childParameterizedInstanceMethod() {30    let child = Child()31    child.parameterizedInstanceMethod(10)32}33func childParameterizedInstanceMethod() {34    let child = Child()35    child.parameterizedInstanceMethod(10)36}37func childParameterizedInstanceMethod() {38    let child = Child()39    child.parameterizedInstanceMethod(10)40}41func childParameterizedInstanceMethod() {42    let child = Child()43    child.parameterizedInstanceMethod(10)44}

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1func childParameterizedInstanceMethod() {2    print("Child class parameterized instance method")3}4func childParameterizedInstanceMethod() {5    print("Child class parameterized instance method")6}7func childParameterizedInstanceMethod() {8    print("Child class parameterized instance method")9}10func childParameterizedInstanceMethod() {11    print("Child class parameterized instance method")12}13func childParameterizedInstanceMethod() {14    print("Child class parameterized instance method")15}16func childParameterizedInstanceMethod() {17    print("Child class parameterized instance method")18}19func childParameterizedInstanceMethod() {20    print("Child class parameterized instance method")21}22func childParameterizedInstanceMethod() {23    print("Child class parameterized instance method")24}25func childParameterizedInstanceMethod() {26    print("Child class parameterized instance method")27}28func childParameterizedInstanceMethod() {29    print("Child class parameterized instance method")30}31func childParameterizedInstanceMethod() {32    print("Child class parameterized instance method")33}34func childParameterizedInstanceMethod() {35    print("Child class parameterized instance method")36}37func childParameterizedInstanceMethod() {38    print("Child class parameterized instance method")

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1func childParameterizedInstanceMethod (x: Int) -> Int {2}3func childParameterizedClassMethod (x: Int) -> Int {4}5func childParameterizedClassMethod (x: Int) -> Int {6}7func childParameterizedClassMethod (x: Int) -> Int {8}9func childParameterizedClassMethod (x: Int) -> Int {10}11func childParameterizedClassMethod (x: Int) -> Int {12}13func childParameterizedClassMethod (x: Int) -> Int {14}15func childParameterizedClassMethod (x: Int) -> Int {16}17func childParameterizedClassMethod (x: Int) -> Int {18}19func childParameterizedClassMethod (x: Int) -> Int {20}21func childParameterizedClassMethod (x: Int) -> Int {22}23func childParameterizedClassMethod (x: Int) -> Int {24}

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1import UIKit2class funcClass {3    func childParameterizedInstanceMethod(a: Int) -> Int {4    }5}6class funcChildClass: funcClass {7    func childParameterizedInstanceMethod(a: Int) -> Int {8    }9}10var childClass = funcChildClass()11print(childClass.childParameterizedInstanceMethod(5))12import UIKit13class funcClass {14    func childParameterizedInstanceMethod(a: Int) -> Int {15    }16}17class funcChildClass: funcClass {18    func childParameterizedInstanceMethod(a: Int) -> Int {19    }20}21var childClass = funcChildClass()22print(childClass.childParameterizedInstanceMethod(5))23import UIKit24class funcClass {25    func childParameterizedInstanceMethod(a: Int) -> Int {26    }27}28class funcChildClass: funcClass {29    func childParameterizedInstanceMethod(a: Int) -> Int {30    }31}32var childClass = funcChildClass()33print(childClass.childParameterizedInstanceMethod(5))34import UIKit35class funcClass {36    func childParameterizedInstanceMethod(a: Int) -> Int {37    }38}39class funcChildClass: funcClass {40    func childParameterizedInstanceMethod(a: Int) -> Int {41    }42}43var childClass = funcChildClass()44print(childClass.childParameterizedInstanceMethod(5))45import UIKit46class funcClass {47    func childParameterizedInstanceMethod(a: Int) -> Int {48    }49}50class funcChildClass: funcClass {51    func childParameterizedInstanceMethod(a: Int) -> Int {52    }53}54var childClass = funcChildClass()55print(childClass.childParameterizedInstanceMethod(5))

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1func childParameterizedInstanceMethod (value: Int) {2    print("childParameterizedInstanceMethod called")3}4func childParameterizedInstanceMethod (value: Int) {5    print("childParameterizedInstanceMethod called")6}7func childParameterizedInstanceMethod (value: Int) {8    print("childParameterizedInstanceMethod called")9}10func childParameterizedInstanceMethod (value: Int) {11    print("childParameterizedInstanceMethod called")12}13func childParameterizedInstanceMethod (value: Int) {14    print("childParameterizedInstanceMethod called")15}16func childParameterizedInstanceMethod (value: Int) {17    print("childParameterizedInstanceMethod called")18}19func childParameterizedInstanceMethod (value: Int) {20    print("childParameterizedInstanceMethod called")21}22func childParameterizedInstanceMethod (value: Int) {23    print("childParameterizedInstanceMethod called")24}25func childParameterizedInstanceMethod (value: Int) {26    print("childParameterizedInstanceMethod called")27}28func childParameterizedInstanceMethod (value: Int) {29    print("childParameterizedInstanceMethod called")30}31func childParameterizedInstanceMethod (value: Int) {32    print("childParameterizedInstanceMethod called")33}34func childParameterizedInstanceMethod (value: Int) {

Full Screen

Full Screen

childParameterizedInstanceMethod

Using AI Code Generation

copy

Full Screen

1func childParameterizedInstanceMethod(_ a: Int) -> Int {2}3func childParameterizedInstanceMethod(_ a: Int, _ b: Int) -> Int {4}5func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int) -> Int {6}7func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int, _ d: Int) -> Int {8}9func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int, _ d: Int, _ e: Int) -> Int {10}11func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int, _ d: Int, _ e: Int, _ f: Int) -> Int {12}13func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int, _ d: Int, _ e: Int, _ f: Int, _ g: Int) -> Int {14}15func childParameterizedInstanceMethod(_ a: Int, _ b: Int, _ c: Int, _ d: Int

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockingbird automation tests on LambdaTest cloud grid

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

Most used method in func

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful