Skip to content

Latest commit

 

History

History
90 lines (75 loc) · 3.57 KB

Supported features.md

File metadata and controls

90 lines (75 loc) · 3.57 KB

Supported features

Generation:

All supported ways of generating mocks. Handling mockable types:

  • generating inline mocks
  • generate in Mocked.generated based on AutoMockable protocol
  • generate in Mocked.generated based on AutoMockable annotation
  • skip protocols that cannot be generated with warning
  • support protocol inheritance
  • support objc protocols (with special protocol/annotation)
  • support generic protocols - see Generics section for more information !!!

Stubbing:

Support for stubbing protocol members:

  • stubbing initializers only for protocol conformance - they have empty implementation!
  • stubbing deinitializers
  • stubbing instance methods
    • with return value
    • with return as Swift.Never
    • that throws
    • that rethrows
  • stubbing static methods
  • stubbing generic methods
    • constrained to protocol conformance
    • with 'T.Type' attributes
    • constrained to Self type
  • stubbing variables (with get, set)
    • instance variables
    • static variables
    • optional
    • implicitly unwrapped optional
  • stubbing subscripts - for generic subscripts manual annotation needed
  • handling associated types - done by annotations
  • handling conformances in associated types
  • wrapping method attributes as Parameter
    • basic types
    • closures
    • @escaping closures
    • typealiases

Given

Usage of Given to specify return value and error thrown for stubbed methods:

  • constraint to attributes matching .any
  • constraint to attributes matching explicit .value(ValueType) where:
    • ValueType is Equatable
    • ValueType is Sequences of Equatable elements
    • ValueType is not Equatable - when registered comparator in Matcher
    • ValueType is Equatable is @escaping closure - when registered comparator in Matcher
    • !!! ValueType is not @escaping closure - always handled as .any
  • return value for instance stub
  • error thrown for instance stub
  • error thrown for instance stubs that rethrows
  • return value for static stubs
  • error thrown for static stubs
  • error thrown for static stubs, that rethrows

Perform

Usage of Perform to execute closure, when stubbed method is called:

  • perform closure attributes matching stub attributes
  • constraint to attributes matching .any
  • constraint to attributes matching explicit .value(ValueType) where:
    • ValueType is Equatable
    • ValueType is Sequences of Equatable elements
    • ValueType is not Equatable - when registered comparator in Matcher
    • ValueType is Equatable is @escaping closure - when registered comparator in Matcher
    • !!! ValueType is not @escaping closure - always handled as .any
  • expect perform closure for static stubs

Verify

Usage of Verify to check, whether specific stubbed method was called on Mock

  • constraint to attributes matching .any
  • constraint to attributes matching explicit .value(ValueType) where:
    • ValueType is Equatable
    • ValueType is Sequences of Equatable elements
    • ValueType is not Equatable - when registered comparator in Matcher
    • ValueType is Equatable is @escaping closure - when registered comparator in Matcher
    • !!! ValueType is not @escaping closure - always handled as .any
  • verify if called at least once
  • verify if called exactly number of times
  • verify for static methods