-
Notifications
You must be signed in to change notification settings - Fork 268
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
Unit tests take too long to run #133
Comments
The biggest culprit by far would by TyphoonTestUtilsTests - it's testing asynch. You could just the values in there to be much, much smaller and should be good after that. |
Ahh, interesting, thanks. How about deleting TyphoonTestUtils and their corresponding tests? We don't use them anywhere. We should really try to avoid asynchronous unit tests at all costs. If it has to be asynchronous, it's really an integration or acceptance test and can stand to be run less often (by being on a different target). |
Removed in df1457a. Tests run in .2 seconds now. We can always revert. |
Its not for us, it’s for anyone who wants to write an integration test involving threads - eg a network request. . Similar to Kiwi, Cedar & Expecta asynch matchers. Docs are here: https://github.com/typhoon-framework/Typhoon/wiki/Configuration-Management-%26-Testing I use it all the time in my projects. |
This is not an integration test. This is a UNIT TEST for a utility that provides features to help with Integration Testing |
Sorry about that Jasper, I wasn't aware that was part of the public API. My apologies. I got a little gung-ho, I should have waited to consult with you before removing that. Having that utility in Typhoon seems a bit out of scope to me. I didn't at all expect that we would be providing features to users to help out with asynchronous integration tests. It doesn't seem like it fits with the rest of the library, although I appreciate the usefulness. I've spent lots of time trying to write asynchronous tests and have written some similar code myself. The same goes for the String and URL utilities which don't look like they are used in Typhoon itself. There aren't that many Utils at the moment, but I think the focus of Typhoon would benefit from being forked off into a seperate project. A JasperKit, perhaps? :) Considering how to classify the TestUtilTests tests themselves— I think the interaction with NSRunLoop, and more generally with the concept of passing time, hints at another abstraction that should be introduced. It certainly makes testing difficult. I consider asynchronous unit tests to be a code smell. Off the top of my head, to make the tests for the TestUtils synchronous I would consider introducing a class (let's call it The I saw you lowered the timeout on the |
Thanks for your feedback . . and will definitely keep Typhoon focused. Wrt to moving TyphoonTestUtils though, the answer is no. This has been in Typhoon since day one, essentially. I value 100% Unit Test coverage. I also value Integration Tests, to see the units working together, and that's what this utility is for. The test case is a unit test, because it is testing the contract of this utility - so providing asynch is a special case here. When I opened-up Typhoon for contributions I knew that we'd get a lot of velocity and new ideas. When working in a team scenario like this there's always going to be one or two things that you don't like. . . (or if you really have a lot of different ideas, you can always fork and strike out in a new direction). There's lots of other ways we can test this class if it becomes a problem - and simply moving it out of the project is not the direction I want to take. |
Relates to: #74 |
You're welcome! Don't get me wrong, I agree that This is the more philosophical question of what services we want Typhoon to provide to users. We bill ourselves as a dependency injection container. What I'm wrestling with is: where does making writing integration tests easier fit in with that mission? Or are the utils for our own future use, when testing parts of Typhoon? |
Typhoon core is indeed just a powerful dependency injection container. . . (with one or two extra utils in there). . Its main strength is providing a powerful core - the DI metadata is de-coupled, allowing for different types of expression - block-style, XML, macros, and future innovations. I don't have plans to be like Spring and do everything but the kitchen sink (hang on! . . . a kitchen-sink module would be kinda cool right?), however I am planning on the following:
And most importantly: _your fantastic ideas and innovations_ . . . now that we have the typhoon-framework module in GitHub we can keep code organized into modules there. . This way we can publish a few different configs in CocoaPods: core, light, test-utils . . . maybe even AOP ? (AOP would be really simple to implement in Obj-C) |
Aha, great idea! I like the modules idea, particularly as we grow more. typhoon-core etc. https://github.com/rspec/rspec does this too. This makes more sense to me, and it feels like the Regarding AOP, I think that would be fantastic. I'm not terribly familiar with the idea myself but am keen to learn. It's certainly a very interesting idea, and seems underserved. The biggest Obj-C implementation I could find: https://github.com/moszi/AOP-in-Objective-C |
A 2 minute summary of AOP Sometimes we have requirements that break OOP. They can be infrastructure requirements (security, transaction management, sophisticated logging) or business requirements (every time a customer interacts with the store, track their behavior and make a genius-bar suggestion). . . . These are the kinds of requirements that cut-across many modules. . . In AOP-speak we call them cross-cutting concerns. Why do these requirements break OOP. The three principles are encapsulation (aka modularization), polymorphism and inheritance. Using encapsulation we might have a class that's has a single-responsibility related to making purchases from a store. With these cross-cutting concerns, the class has to do a whole bunch of stuff before/after its main responsibility.
. . and worse we have to repeat these everywhere. DI won't help us here - we could pass around an AuditService, TransactionManager, GeniusTracker, etc in the API of the service, but that would make for a very ugly interface. So what AOP does is allow you to :
A great way to learn about AOP is to try it in Spring - they make it easy to get started. |
Right, cross-cutting concerns! Thanks for the quick refresher. I'll definitely play around with Spring AOP a bit. |
Thanks for pointing that framework out - hadn't seen that one before. Only justin Spahr-summers' experimental one in libextobjc.. . The simple proxy approach taken in the one you pointed out would suit us we'll if we're only going to intercept container-built instances - eg you can use AOP for any object built by Typhoon, (as opposed to any object full-stop). . What's missing in that lib seems to be the point-cut expression language. Getting off topic here though ;) |
Feeding onto the OT-discussion. Have been thinking for a while of writing a proxy-based AOP lib for objective-c, inspired by Spring AOP which I've enjoyed working with quite a lot in the past. Had some time in between christmas meals and produced a foundation at least: Still missing some stuff:
... and it needs some proper testing. If we are interested in going with a proxy approach in Typhoon. I think it's probably a good idea to introduce a ComponentPostProcessor, and have an implementation that can automatically proxy components based on the declared aspects in the container. Move the AOP discussion to a separate issue perhaps? :-) |
Sure, sounds good to me. Or even to a separate typhoon-aop repo. |
Closing - trying to get the issues list down to a set of immediately actionable tickets. |
~5 seconds on my machine.
We have some acceptance tests coexisting with the unit tests, perhaps we should move some of those into a different target.
The text was updated successfully, but these errors were encountered: