Coder Social home page Coder Social logo

Comments (8)

BlackHC avatar BlackHC commented on July 20, 2024

This is not easily possible because you cannot correct proxies with the correct type dynamically :(

from mockito.

vikerman avatar vikerman commented on July 20, 2024

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.

matanlurey avatar matanlurey commented on July 20, 2024

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.

vikerman avatar vikerman commented on July 20, 2024

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.

TedSander avatar TedSander commented on July 20, 2024

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.

Andersmholmgren avatar Andersmholmgren commented on July 20, 2024

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.

BlackHC avatar BlackHC commented on July 20, 2024

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.

TedSander avatar TedSander commented on July 20, 2024

Closing this as transformers are no longer recommended by the dart team

from mockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.