Git Product home page Git Product logo

mimus's People

Contributors

adiki avatar eluss avatar jonreid avatar kamwysoc avatar karolus avatar paweldudek avatar pkozielecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mimus's Issues

Display argument values if they mismatch

Right now if we get arguments mismatch Mimus will print out

failed - Call with identifier x was recorded, but arguments didn't match

Which is a bit too cryptic, we could use Swifts CustomStringConvertible and String(describing: ) to display captured and expected values, this would be helpful when debugging failures.

Edit: OCMockito has an amazing reporting similar to what we want to achieve here:

Argument(s) are different!
Wanted: start:"Fixture App Center Identifier" withServices:<(
)>
Actual invocation has different arguments:
start:@"Fixture App Center Identifier" withServices:@[MSAnalytics, MSCrashes]

Mismatch in 2nd argument. Expected <(
)>, but was <(
    MSAnalytics,
    MSCrashes
)>

MyApp -[AppConfigurator configureAppWithConfiguration:] + 397

Find a way to allow usage of `Matcher` class within custom matcher implementations.

Right now custom matchers might require complicated logic as they cannot leverage internal components of Mimus.

For instance, consider following scenario. We're trying to write a custom matcher for URLRequest. In that matcher we need to compare URL? and [String: String]?.

That means we need to do the usual dance of unwrapping, checking for equality etc:

public func equalTo(other: MockEquatable?) -> Bool {
    if let otherURLRequest = other as? URLRequest {

        var urlsMatch = false
        var headersMatch = false

        if self.url == nil, otherURLRequest.url == nil {
            urlsMatch = true
        } else {
            if let actualURL = otherURLRequest.url, let expectedURL = self.url {
                urlsMatch = actualURL == expectedURL
            }
        }

        if self.allHTTPHeaderFields == nil, otherURLRequest.allHTTPHeaderFields == nil {
            headersMatch = true
        } else {
            if let actualHeaders = otherURLRequest.allHTTPHeaderFields, let expectedHeaders = self.allHTTPHeaderFields {
                headersMatch = actualHeaders == expectedHeaders
            }
        }

        //TODO: Move this to Mimus? Find a way we can leverage Mimus.Matcher
        return urlsMatch && headersMatch
    }

    return false
}

This could be greatly simplified by using Mimus Matcher class:

public func equalTo(other: MockEquatable?) -> Bool {
    if let otherURLRequest = other as? URLRequest {
        let matcher: Mimus.Matcher = // Get the matcher from somewhere?

        return matcher.match(expected: [self.url, self.allHTTPHeaderFields], actual: [otherURLRequest.url, otherURLRequest.allHTTPHeaderFields])
    }

    return false
}

Add infrastructure to simplify returning values from functions

Right now there's no way to easily say "for these set or arguments return this value". We already have infrastructure for recording calls, matchers and matching arguments so this should not be that complicated (albeit this sounds like famous last words).

Improve verification modes error messaging

Basically for following scenario there is a usability issue:

  1. Expect two calls
  2. Two calls are recorded, but one has different arguments.

In this case the message will be Call with identifier xyz was recorded 1 times, but expected at least 2. Would be nice to handle this so the the programmer knows 1 call matches, but there's another one with different arguments.

Somewhat related to #13.

Allow to specify `any` arguments for verification calls

Right now you need to pass exact argument count:

object.verifyCall(withIdentifier: "identifier", arguments: [AnyMatcher(), AnyMatcher()])

Would be nice to specify this as any matcher in general:

object.verifyCall(withIdentifier: "identifier", arguments: .any])

We could leverage ExpressibleByArrayLiteral for this.

Add InstanceOf<T> matcher

class InstanceOf<T>: MockEquatable {

    func equalTo(other: MockEquatable?) -> Bool {
        return other is T
    }
}

We will need to make minor adjustments to how types are hold though.

Add matcher for URL type

Looks like we've forgot to add support for Swift URL type. Might be a good idea to throw in support for NSURL as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.