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?

antonmi

antonmi

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”.

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 | Curated list of awesome lists | Project-Awesome.org.

Where Next?

Popular in Libraries Top

josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 11851 134
New
Crowdhailer
The latest release of Ace (0.10.0) includes serving content over HTTP/2. I have started writing a webserver to teach my self more about...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. Features Unstyled Phoenix components. Storybook that can be added to...
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
KallDrexx
For a good number of months I've been working on creating a very basic RTMP live video streaming server. Now that I have a very, very ba...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New

Other popular topics Top

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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
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
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Sub Categories:

We're in Beta

About us Mission Statement