Comments (8)
This is not easily possible because you cannot correct proxies with the correct type dynamically :(
from mockito.
I am not suggesting generating the type dynamically during runtime. I am suggesting generating the code that would otherwise be written by hand using a build Transformer, since the pattern seems to be mostly the same. Would that be doable?
from mockito.
Is mock() with a transformer really that much of a benefit over the 2 lines you need otherwise? Plus all of your tests will now need a transformer to even work.
from mockito.
Would it really add benefit? I guess that's the main question that needs to be answered and I don't actually know. My gut feeling was anything that would reduce developer friction while writing unit tests would be useful. I just felt it odd to repeat the same pattern over and over again and felt it could be automated.
There is also either duplication of mocked classes across test files or extra effort to collect the mocked class in a common place. Not sure how big of a problem that is either.
What sort of data would be helpful in this regard? The average number of mocked classes per unit test file? The average percentage of lines in test that goes towards writing mocks? Instances of mocked class duplications?
Regarding it being a transformer - Adding -mockito to transformers in pubspec.yaml shouldn't be difficult and we should have the default mock() implementation throw an actionable exception message saying you need to add mockito to your transformers in case it's missing. Old tests not using mock() will continue to work without the transformer.
from mockito.
Having less code needs to be carefully balanced with having too much "magic." Magic is great when it works, but when it doesn't it is a cause of a lot of developer angst.
I don't think this savings is worth the added complexity/latency that is added to the build chain. That said if you want to setup a prototype and see how it turns out.
from mockito.
You can of course always split out mocked classes into helper files so you
can share them between tests.
On Fri, 4 Sep 2015 at 5:08 am, Ted Sander [email protected] wrote:
Having less code needs to be carefully balanced with having too much
"magic." Magic is great when it works, but when it doesn't it is a cause of
a lot of developer angst.I don't think this savings is worth the added complexity/latency that is
added to the build chain. That said if you want to setup a prototype and
see how it turns out.—
Reply to this email directly or view it on GitHub
https://github.com/fibulwinter/dart-mockito/issues/20#issuecomment-137544441
.
from mockito.
I think the proxy issue needs to be solved in general. We're half way
there, and that's always an unfortunate location to be in ^^
On Thu 3 Sep 2015 at 22:27 Andersmholmgren [email protected] wrote:
You can of course always split out mocked classes into helper files so you
can share them between tests.On Fri, 4 Sep 2015 at 5:08 am, Ted Sander [email protected]
wrote:Having less code needs to be carefully balanced with having too much
"magic." Magic is great when it works, but when it doesn't it is a cause
of
a lot of developer angst.I don't think this savings is worth the added complexity/latency that is
added to the build chain. That said if you want to setup a prototype and
see how it turns out.—
Reply to this email directly or view it on GitHub
<
https://github.com/fibulwinter/dart-mockito/issues/20#issuecomment-137544441.
—
Reply to this email directly or view it on GitHub
https://github.com/fibulwinter/dart-mockito/issues/20#issuecomment-137564456
.
from mockito.
Closing this as transformers are no longer recommended by the dart team
from mockito.
Related Issues (20)
- Verify constructor HOT 1
- How to test retrofit services with mockito HOT 6
- Question: dockito in dev_dependies? HOT 1
- Error The included part 'mocks.dart' must have a part-of directive. HOT 1
- `verify` failing test but showing in "All calls" HOT 1
- mockito:mockBuilder generator fail using MockSpec custom superclass HOT 5
- How to mock Dio.interceptors.add? HOT 1
- Support for extension-type/inline-class HOT 3
- Why is build_runner is succeeding with 0 outputs? HOT 3
- Support for real executions on Mocking classes HOT 1
- Bad state: Cannot call `when` within a stub response HOT 7
- Cannot create Mock in Dart 3.x: type 'Null' is not a subtype of type 'IOSink' HOT 1
- 'Null' is not a subtype of type 'Future<bool>' HOT 3
- Mocking a class which is created at runtime HOT 1
- Breaking change or typo? HOT 2
- How are we supposed to use any with non null parameters? HOT 2
- Extension type with generic
- Cannot generate mocks for class with method with parameter with default value with a single quote HOT 6
- Dart 3.4.3: invocation_matcher.dart Error: The class 'DeepCollectionEquality' can't be extended outside of its library because it's a final class. HOT 1
- Bad state: Asset URI is missing for abstract class JSObject HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockito.