Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Tests? #47

Closed
Closed

Description

@tmcw

Since this is a minimal new start and we have some freedom, could we write tests? KIF, kiwi and gh-unit look like decent options for ObjC.

Activity

  1. incanus commented on Feb 25, 2014

    @incanus
    Contributor

    HELL YES. I would love to get on this before the project keeps growing, though it slipped my mind. Testing culture in Objective-C is not good, but this is a light enough library that I think it makes sense to cut our teeth on it, find our way around, and then expand it into our other iOS work.

  2. mick commented on Feb 26, 2014

    @mick

    Cedar is a good option. You can see what it looks like in action on @boundsj's mapbox-ios-sdk test branch

  3. incanus commented on Feb 26, 2014

    @incanus
    Contributor

    I am thinking offhand that we do this at the Xcode level, ideally integrated with Travis since GitHub supports it and we use it for JS-y projects, but that might be a stretch for the hosted Travis platform. So, in Xcode meaning you can change to the target anytime you like to run tests, plus somehow integrated into our release flow. For an app, I would say this is the Archive part of the scheme, but for libraries, we don't really archive so maybe something like Makefile-driven "make test" as part of a checklist.

  4. tmcw commented on Feb 26, 2014

    @tmcw
    ContributorAuthor

    Let's not think about Travis / running this periodically / blocking git commits at this point: just being able to run test in the repository and see a ✔ would be great for contributors and for maintainers doing refactoring.

  5. incanus commented on Feb 26, 2014

    @incanus
    Contributor

    Agree with @tmcw. I do like the CocoaPods automation idea @wsnook, but honestly that's more useful to me in http://github.com/mapbox/mapbox-ios-sdk than here, though we can reevaluate as the project grows.

  6. ghost added a commit that references this issue on Feb 27, 2014
  7. boundsj commented on Feb 27, 2014

    @boundsj

    Hi @incanus @wsnook @tmcw. I set up cedar specs, a rake file for running the tests from the command line, and have automated builds and tests running in travis for my fork of mbxmapkit.

    Where I work, all of our objc projects are test driven using cedar (a BDD framework that we built in house that eventually inspired others like kiwi) and with full CI - usually on travis or or Jenkins instance on a mac mini.

    You can see the CI status here: https://travis-ci.org/boundsj/mbxmapkit
    The (albeit massive) commit to make all of this work is here: boundsj@bbc2683
    (note: my fork has the super awesome travis build status badge in the readme: https://github.com/boundsj/mbxmapkit 😎 )

    Most of the changes were administrative - I housed the files in a project as an ios static lib, (I know the MO is to keep things simple but it seems it might be time for this project to grow up just a little bit... it'll still be simple enough as a static lib for ios/osx), I added a rake file, I added cedar specs. You can read all about how cedar works on it's repo but basically, you install it system wide and it comes with xcode plugins so things "just work".

    The most salient addition is https://github.com/boundsj/mbxmapkit/blob/master/mbxmapkit/Specs/MBXMapKitSpec.mm. In this file I demonstrate a few of the basics of BDD testing objc code. An MBXMapView is initialized and then we test that it's behavior is correct. For example, did it make a request for tiles? Spies and fakes are used to control flow under spec.

    It's probably worth noting that this test really ends up testing the "updateOverlay" method of MBXMapView. The current design is a bit odd and a little hard to test. For example, updateOverlay calls itself recursively, infinitely if there are network and/or non-200 response codes. But, I'm not sure I would've noticed this awkwardness if I were not thinking about how to write a behavioral test for it. Also, there are GCD calls made in "updateOverlay" that would be nice to pull out into separate objects so the asynchronous behavior can be forced to be synchronous under test.

    In any case, I hope you consider doing this or something like this. I'd encourage you to use a BDD framework like cedar (it is truly awesome and well supported but I'm biased) or, if not, kiwi. BDD frameworks have several advantages over the more traditional unit testing frameworks (like Apple provides). I think an amazing open source project like this deserves a great testing framework for it's contributors and for the sake of long term sustainability.

    If any of you are ever in the SF office and want to pair on writing tests let me know - I'd be happy to stop by and give a more detailed tour in person.

  8. incanus commented on Mar 18, 2014

    @incanus
    Contributor

    @boundsj, this is great stuff. I think I follow. I see how MBXMapKitSpec.mm is testing that the use of a mapID in effect adds an overlay and that overlay results in a TileJSON request by spying on the NSURLSession. I would be interested in learning conceptually how this could be taken further, especially with a lot of UI results being the end state.

    If any of you are ever in the SF office and want to pair on writing tests let me know - I'd be happy to stop by and give a more detailed tour in person.

    In fact, I will be there tomorrow through Friday, though I know this is late notice. Would love to sit down and discuss this a bit if you've got some time.

  9. boundsj commented on Mar 18, 2014

    @boundsj

    Thanks @incanus. I'll check with @mick to see when it might work out to meet up.

  10. incanus commented on Aug 27, 2014

    @incanus
    Contributor

    We've got a good thing going with KIF & Travis over in GL Cocoa and should replicate that if we do another sprint on this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions