mudasobwa

mudasobwa

Creator of Cure

Elixir library to execute `ExUnit` tests as `common_test`

I wanted to release v0.1.0 of this library in 2023, that’s why it’s still very much WIP, although fully functional already.

There was an intent to bring common_test to Elixir by @hauleth, but it seems dead.

I needed to use :peer for some specific tests and I started by adopting it for Elixir users. Soon I figured out, I wanted common_test to be easily usable from Elixir and apparently we have everything already in place to make it as easy as use Enfiladex.

Usage: add :enfiladex dependency and put use Enfiladex.Suite after use ExUnit.Case in your tests to make them run by common_test with newly introduced task MIX_ENV=test iex --sname am -S mix enfiladex.

Limitations:

  • on_exit/2 callbacks with captures makes test to fail compiling with use Enfiladex (Code.with_diagnostics/2 issue),
  • Enfiladex.{peer/3, multi_peer_/3} fail from tests with an anonymous function,
  • MIX_ENV=test iex --sname am -S mix enfiladex (named node) to execute common test,
  • compiled beam files are not yet removed.

I have no issues fixing all but the first one. It’s induced by Code.with_diagnostics/2 leaving error in the compiler errors accumulator even if handled and processed when executed in compile time.

I need it to detect whether on_exit/2 might be reused as end_per_*** callbacks in common_test. If it grabs context variables, it should be discarded. I am most likely to file an issue in Elixir core, although I understand this use-case is extremely uncommon.

Everything else is kinda working, as well as exported from Enfiladex functions

  • peer(fun, callback \\ [], config \\ [])
  • multi_peer(fun, callback \\ [], config \\ [])

Both accept a function to be executed on :peer, a callback, and an optional config:

  • transfer_config :: boolean()
  • start_applications :: boolean()
  • nodes_count :: non_neg_integer()

The docs are pending. Enjoy! enfiladex v0.1.0 — Documentation

P. S. one might test it with running MIX_ENV=test iex --sname am -S mix enfiladex in enfiladex itself after git clone.

First Post!

mudasobwa

mudasobwa

Creator of Cure

Fixed some cosmetics and introduced tasks.

❯ mix enfiladex.ex_unit
...

Finished in 1.1 seconds (0.00s async, 1.1s sync)
3 tests, 0 failures

Randomized with seed 362051
❯ mix enfiladex

Common Test starting (cwd is /home/aleksei/Proyectos/Elixir/enfiladex)



CWD set to: "/home/aleksei/Proyectos/Elixir/enfiladex/ct_logs/ct_run.enfiladex@ALEKSEI-ThinkPad-X1-Carbon-Gen-9.2024-01-02_11.04.47"

TEST INFO: 1 test(s), 3 case(s) in 0 suite(s)

Testing Elixir.enfiladex.Elixir.Enfiladex.Test.Suite: Starting test, 3 test cases
...Testing Elixir.enfiladex.Elixir.Enfiladex.Test.Suite: TEST COMPLETE, 3 ok, 0 failed of 3 test cases

Updating /home/aleksei/Proyectos/Elixir/enfiladex/ct_logs/index.html ... done
Updating /home/aleksei/Proyectos/Elixir/enfiladex/ct_logs/all_runs.html ... done
[{3, 0, {0, 0}}]

... in both cases are passed tests.

Where Next?

Popular in Libraries Top

marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: https://github.com/devonestes/assertions ...
New
treble37
Just looking for a little feedback on a tiny helper library I built - Sometimes I find the need to convert maps with atom keys to maps...
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
ericlathrop
I built a silly site for Halloween that uses Phoenix Channels on the backend, and React on the frontend. I had many problems integrating ...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New

Other popular topics Top

aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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 42633 214
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
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

Sub Categories:

We're in Beta

About us Mission Statement