antonmi

antonmi

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!

Most Liked

Azolo

Azolo

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.

antonmi

antonmi

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

bobbypriambodo

bobbypriambodo

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?

Last Post!

drl123

drl123

FYI I’ve successfully used ESpec with the JetBrains IDE test runner with the Elixir plugin. It will let you set the entire test suite to run, or a subset of the tests in a loop, monitoring for changes in the file system similar to Guard. You can even use it in debug mode where you can set breakpoints and interact with the state of the app in the middle of the test like PRY. Lately, though, I’ve migrated to purely Exunit tests.

If you are looking for a pure CLI tool, there are a few in the list here: Awesome Elixir — Project Awesome.

Where Next?

Popular in Announcing Top

Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_orde...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19870 141
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
fuelen
Hey folks! Want to present a toolkit for writing command-line user interfaces. It provides a convenient interface for colorizing text...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36689 110
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement