ESpec - Elixir Behaviour Driven Development

Hi, colleagues!

I’ve discovered this awesome forum recently and I wanna share my projects and ideas.
First of all, I create a topic about ESpec testing framework.
ESpec is inspired by RSpec Ruby library and implements its DSL.

There is also espec_phoenix project - a lightweight wrapper around ESpec which brings BDD to Phoenix web framework.

Let’s discuss your questions or proposals here!

Thank you!

4 Likes

Hi! I’ve never used Ruby (and therefore, RSpec) before, I’ve skimmed through the (quite long) readme and you said

It is NOT a wrapper around ExUnit but a completely new testing framework written from scratch.

I apologize for the basic question, but what exactly does ESpec have that ExUnit doesn’t? Why would I use it over ExUnit?

1 Like

I think it’s not necessarily a difference in functionality as much as style.

I don’t like calling Espec and Rspec BDD because I don’t think they are necessarily “pure” BDD like Cucumber is.

But the style is cleaner, the DSL is robust, and it tries to be “readable”. It basically has the same end result but a different way to get there.

Some people swear by RSpec in the Ruby world. Personally, I just used whatever I’m told to or what’s more convenient.

I do think that if you haven’t ever used a library with the expect/should you should. It definitely promotes a different way of thinking that causes you to write tests a little bit differently, which led me to write better tests overall.

Plus you may enjoy using that style better than an assert style.

2 Likes

Hi, Bobby!
Thanks for interesting in ESpec!
There are many cool features that present in ESpec but does not exist in ExUnit.
Just off the top of my head:

  • Nested context blocks with an ability to specify “before” block in each of them.
  • “let” macro which allows creating “memoizable” functions that caches result across multiple calls.
  • Built-in mocking functionality on top of Erlang “meck” library.
  • “Shared” and “generated” examples wich allows to avoid test duplication.
  • “Custom matchers” for testing specific functionality.

And, of course, the style of tests is different.
You may find some cool examples in ESpec spec folder or there are examples of using in Phoenix project

3 Likes

Hi, Azolo!
I completely agree with you.
ESpec suites have a different style that allows you better describe your test suites, thus making them more like “specification”.

1 Like

Are there any limitations of ESpec? For example, running tests in parallel or working with async gen servers?

Hi, @bzitzow! There are no any limitations. You can do everything you do with ExUnit and even more!)