Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mock for "Route" entity for Unit Testing #376

Open
nastasiupta opened this issue Jul 25, 2019 · 3 comments
Open

Create a mock for "Route" entity for Unit Testing #376

nastasiupta opened this issue Jul 25, 2019 · 3 comments
Labels
needs more information Can't proceed without more data.

Comments

@nastasiupta
Copy link

nastasiupta commented Jul 25, 2019

'MapboxDirections.swift', '0.27.3'

I'm writing unit tests for a class that uses a dependency that should return at least one "Route" entity.

For the dependency class, I created a new class by subclassing, and on completion block I want to return a mock object for "Route", but during build time for unit tests I get those issues:

👎 Undefined symbol: type metadata accessor for MapboxDirections.Route
👎 Undefined symbol: MapboxDirections.Waypoint.__allocating_init(coordinate: __C.CLLocationCoordinate2D, coordinateAccuracy: Swift.Double, name: Swift.String?) -> MapboxDirections.Waypoint
👎 Undefined symbol: type metadata accessor for MapboxCoreNavigation.NavigationMatchOptions
👎 Undefined symbol: MapboxCoreNavigation.NavigationMatchOptions.__allocating_init(waypoints: [MapboxDirections.Waypoint], profileIdentifier: __C.MBDirectionsProfileIdentifier?) -> MapboxCoreNavigation.NavigationMatchOptions
👎 Undefined symbol: type metadata accessor for MapboxDirections.Waypoint
👎 Undefined symbol: _MBDirectionsProfileIdentifierAutomobile
👎 Undefined symbol: MapboxDirections.Directions.shared.unsafeMutableAddressor : MapboxDirections.Directions

@1ec5
Copy link
Contributor

1ec5 commented Jul 26, 2019

For the dependency class, I created a new class by subclassing, and on completion block I want to return a mock object for "Route"

What does the subclass look like? Is this the completion block in an override of an existing method, or a completion block of a new method?

The warnings seem to be about every MapboxDirections symbol you’re using in your test bundle. Could there be a naming collision?

@nastasiupta
Copy link
Author

nastasiupta commented Aug 7, 2019

@1ec5 here is what I try to do:
let options = RouteOptions(waypoints: [])
let route = Route(json: [:], waypoints: [], options: options)
let response = MapBoxRouteEntityConvertorWorker.MapBoxRouteResponse(route: route, wayType: .fastest)

And those are the errors:
👎 Undefined symbol: type metadata accessor for MapboxDirections.RouteOptions
👎 Undefined symbol: type metadata accessor for MapboxDirections.Waypoint
👎 Undefined symbol: MapboxDirections.RouteOptions.__allocating_init(waypoints: [MapboxDirections.Waypoint], profileIdentifier: __C.MBDirectionsProfileIdentifier?) -> MapboxDirections.RouteOptions
👎 Undefined symbol: type metadata accessor for MapboxDirections.Route
👎 Undefined symbol: MapboxDirections.Route.__allocating_init(json: [Swift.String : Any], waypoints: [MapboxDirections.Waypoint], options: MapboxDirections.RouteOptions) -> MapboxDirections.Route

And i imported:
import MapboxDirections

@1ec5
Copy link
Contributor

1ec5 commented Jan 7, 2020

Does this issue still persist? We’ve since rewritten the library to use pure Swift instead of bridging to Objective-C. I realize your test is written in Swift, but I wonder if the build errors were related to symbols that were bridging anyways.

@1ec5 1ec5 added the needs more information Can't proceed without more data. label Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more information Can't proceed without more data.
Projects
None yet
Development

No branches or pull requests

2 participants