Coder Social home page Coder Social logo

Mockito without mirrors? about mockito HOT 10 CLOSED

dart-lang avatar dart-lang commented on July 2, 2024
Mockito without mirrors?

from mockito.

Comments (10)

matanlurey avatar matanlurey commented on July 2, 2024

It looks like the only invocation of true mirrors is spy:

dynamic spy(dynamic mock, dynamic spiedObject) {
  var mirror = reflect(spiedObject);
  mock._defaultResponse = () => new CannedResponse(
      null, (Invocation realInvocation) => mirror.delegate(realInvocation));
  return mock;
}

I imagine this could be moved to mockito/spy.dart.

The rest of mirrors uses noSuchMethod, which is a sort of mirrors-light. Is that still supported in Flutter/AOT? We've had a few conversations about code-gen based mockito that had mixed reviews.

from mockito.

matanlurey avatar matanlurey commented on July 2, 2024

It looks like noSuchMethod works for AOT. @TedSander is this a reasonable change?

from mockito.

TedSander avatar TedSander commented on July 2, 2024

Yep seems reasonable. Anyone want to send a pull request? I imagine we shouldn't have a breaking change for this. So have the original entrypoint export spy.dart, and mock.dart (or something like that,) and have AOT just import the second one.

from mockito.

matanlurey avatar matanlurey commented on July 2, 2024

@Hixie does that sound OK?

We'd have:

lib/
  src/
    mock.dart
    spy.dart
  mockito.dart: Original library that also exports spy (won't work in AOT)
  mockito_no_mirrors.dart: Mockito without the spy function (or whatever else is added)

from mockito.

Hixie avatar Hixie commented on July 2, 2024

sgtm

from mockito.

Hixie avatar Hixie commented on July 2, 2024

and thanks for looking at this so quickly! much appreciated.

from mockito.

matanlurey avatar matanlurey commented on July 2, 2024

@TedSander I'll shoot you a PR shortly 💋

from mockito.

matanlurey avatar matanlurey commented on July 2, 2024

@Hixie of course!

from mockito.

matanlurey avatar matanlurey commented on July 2, 2024

Alright, take a look at PR https://github.com/fibulwinter/dart-mockito/pull/28

from mockito.

Hixie avatar Hixie commented on July 2, 2024

Thanks!

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.