Code Monkey home page Code Monkey logo

Comments (4)

implicitly-awesome avatar implicitly-awesome commented on September 22, 2024

Hi, @mindreframer, thank you submitting the issue :) will wipe it out

from swap.

implicitly-awesome avatar implicitly-awesome commented on September 22, 2024

done

from swap.

mindreframer avatar mindreframer commented on September 22, 2024

thanks! I was playing with swap more and noticed that it slows down the execution of tests quite significantly and also does not play well with live code reloaders Cortex... Not sure if that is helpful feedback, yet I think it is going to be tough to provide a fast, correct, nicely behaving module swapper for Elixir that does not require some runtime configuration / preparation... In the end I decided to stick with less magic and a bit cumbersome pattern of taking the module name from application env with default fallback...

https://github.com/happycodrz/flexi/blob/eed717ceaa1396c4f60bea0514e2c65a3084b77f/lib/common.ex#L18

Test execution dropped from 3 seconds to 0.07 seconds...

thanks and good luck!

from swap.

implicitly-awesome avatar implicitly-awesome commented on September 22, 2024

@mindreframer
Yes, I'm familiar with this approach. Simply resolve modules in config and be happy if you have a few of such mocks. Once you get a system bigger and many modules to mock: you will end up with all modules redefined in the application configs. I've faced the issue when in an application the team follows service object (module) pattern and has a lot of such services modules.
It is just another approach with the most less overhead (in terms of performance), but sometimes it is hard to follow.

Swap's approach is mostly for testing purposes when you don't want to deal with configs, behaviours and all this stuff that (obviously) is faster. I tried to invent another alternative to https://github.com/jjh42/mock (which sometimes really hard to read), https://github.com/plataformatec/mox (which needs additional configuration and pre-defined behaviours) and "sandbox" (like that you've shared above).

Anyway, thank you for the feedback, I will think about the performance.

from swap.

Related Issues (1)

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.