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

First Post!

cmo

cmo

Does this mean there is a minimum version of OTP required?

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 v1.0.1

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

Last Post!

filonenko_g

filonenko_g

Hi, now it works great, thank you very much!
As for:

config :efx, :binding_enabled, true

this should also work for us.

Where Next?

Popular in Announcing Top

bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: GitHub - devonestes/assertions: Helpful a...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New

We're in Beta

About us Mission Statement