You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
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.
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.
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.
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.
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".
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.
@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.
Activity
incanus commentedon Feb 25, 2014
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.
mick commentedon Feb 26, 2014
Cedar is a good option. You can see what it looks like in action on @boundsj's mapbox-ios-sdk test branch
incanus commentedon Feb 26, 2014
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.
tmcw commentedon Feb 26, 2014
Let's not think about Travis / running this periodically / blocking git commits at this point: just being able to run
testin the repository and see a ✔ would be great for contributors and for maintainers doing refactoring.incanus commentedon Feb 26, 2014
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.
Add tests
boundsj commentedon Feb 27, 2014
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.
incanus commentedon Mar 18, 2014
@boundsj, this is great stuff. I think I follow. I see how
MBXMapKitSpec.mmis testing that the use of amapIDin effect adds an overlay and that overlay results in a TileJSON request by spying on theNSURLSession. I would be interested in learning conceptually how this could be taken further, especially with a lot of UI results being the end state.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.
boundsj commentedon Mar 18, 2014
Thanks @incanus. I'll check with @mick to see when it might work out to meet up.
incanus commentedon Aug 27, 2014
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.