murrgelb

murrgelb

Efx - A library to declaratively write testable effects

Efx is a library to define and test side effects declaratively. It is basically a very focused mocking framework, reducing implementation overhead and focusing on testable code.

The special thing about it is, that it uses the fairly new ancestor-keys from the process dictionary to track down the bindings for tests event for child-processes and therefore, more tests can be implemented asynchronously.

If you are interested, need more rational or just want to skim the code, you can find out more on our github. We are looking forward to some feedback!

https://github.com/bravobike/efx

The library is also available on hex: efx | Hex

Most Liked

murrgelb

murrgelb

We just added some minor features to Efx 0.2.10:

  • We love to hotfix our code. Efx now allows to paste code directly into your production environment, if needed. Until now this wasn’t possible, because the hard dependency to Mix.env. We fixed that.
  • We fell in love with property based testing, in our case StreamData. Since uncontrolled and slow side effects are a burden in property based testing, Efx is a obvious choice to bind and control them. However, since Efx works in a process scope and StreamData executes multiple tests in the very same process, binding for each test-case doesn’t work. To enable Efx for property based testing, we introduced with_clean_bindings, which can be used in the body of a propery based test to achieve case dependent bindings: EfxCase — Efx v0.2.10

Happy hotfixing, testing and coding!

murrgelb

murrgelb

We just released Efx 1.0.0 :partying_face:

After some input from the community and minor bug fixes, we thought about our own usage patterns and slightly altered the binding-syntax in a backwards compatible way:

  • Bindings are now done using functions captures, e.g. bind(&MyEffects.write/1, fn _ -> :ok end). Before, we had to name the module as a first argument and pass the function name as an atom as the second.
  • Using function captures does not only provide hints for the compiler but also is enables auto completion support for most editors.
  • Given that syntax we can now cover a very common use case that covers 90% of our tests: Returning a constant from bindings. We can now easily create bindings that return one value constantly: bind(&MyEffects.write/1, const: :ok).

Happy coding!

ouven

ouven

It is a mocking library, that doesn‘t need global binding for your test cases. So all mocking and preparation happens directly in your test code. No need for configs or anything else.

I started using it in my projects and it makes testing clearer and easier.

Kudos to @murrgelb

murrgelb

murrgelb

We released some minor updates (currently at version 0.2.6):

  • defeffect can have guards, now
  • defeffect can have catch and rescue in the body defintion
  • we introduced delegateeffect which basically behaves like defdelegate. Delegates can be bound in tests, same as functions defined with defeffect. This is a foundation for combining and reusing effects and effect-modules (tbd).

It’s very awesome to see this library being used and we’re very grateful for the feedback from you!

Happy coding!

murrgelb

murrgelb

We released some new stuff today (Version 0.2.1):

  • Setup bindings once for all tests
    We call these bindings omnipresent. We define them usually in our test_helpers.ex. There is an example in the EfxCase doc.
  • Formatter support
    Formatters recently added braces around defeffect one-liners (e.g. in defeffect foo, do: "hello"). You can now include the library in your formatter config and have the formatter tamed :wink: (see Usage in Readme).

Happy coding!

Where Next?

Popular in Announcing Top

ityonemo
Currently just starting out on a new mini-project - getting zig NIFs to run in elixir. https://github.com/ityonemo/zigler The idea here...
New
mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
wkirschbaum
Hi everyone. We released Spreadsheet a couple of months ago which we have been using internally for parsing xlsx files internally for our...
New
fuelen
Ecto.DevLogger is an alternative logger of SQL queries in development It inlines bindings into the query, so it is easy to copy-paste lo...
New
hauleth
It is library created by me and @abc3. It is simple client for DuckDB, but with small twist when compared with other libraries out there ...
New
yotor_coder
:glowing_star: Looking for Contributors to Join PyraUI Hey everyone :waving_hand: I’ve been working on PyraUI — a modern UI component li...
New
sonic182
Hi everyone, at Doofinder we have been building llm_composer for some new apps, and we thought it could be useful to share it with the co...
New
New
germsvel
PhoenixTest provides a unified way of writing feature tests – regardless of whether you’re testing LiveView pages or static pages. It al...
New
waseigo
I saw this LinkedIn post: *Can your programming language do this? This is a macro in Clojure called `dotrace`. When you surround a pie...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement