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

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
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
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: GitHub - tmbb/phoenix_ws: Websockets implemented over Phoenix Ch...
New
dominicletz
Hi, I thought I had posted my library before but seems I hadn’t. The project is still in early stages but it’s growing and so I think it...
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 14585 119
New

Other popular topics Top

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 records...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
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

We're in Beta

About us Mission Statement