archan937
ExUnited - Easily spawn Elixir nodes (supervising, Mix configured, easy asserted / refuted) within ExUnit tests
Hi all,
ExUnited is a Hex package designed to easily facilitate spawning supervising local Elixir nodes within tests. Unfortunately, I was not able to properly setup a spawned node for supervisioning with the Erlang :slave.start_link/1 function. So I have written ExUnited to accomplish that, along with supporting Mix.Config configurations, additional loaded code, and a developer friendly way of writing assertions and refutations in the context of a spawned node which really improved the readability of the tests and more.
Features
- Spawn nodes for testing purposes
- Spin up “partially connected” vs “fully connected” nodes
- Run in “verbose” mode which prints a colorized STDOUT of the nodes
- Specify extra “code paths” which will be included (
config.exsincluded) - Support child supervisioning within a spawned node
- Exclude certain dependencies for spawned nodes
- Easily assert and refute within the context of spawned nodes
Example
defmodule MyNodeClusterTest do
use ExUnited.Case
setup do
{:ok, spawned} =
ExUnited.spawn(
david: [code_paths: ["test/nodes/beckham"], supervise: [David]]
)
on_exit(fn ->
ExUnited.teardown()
end)
spawned
end
test "executes code in spawned node", spawned do
assert :"captain@127.0.0.1" = Node.self()
refute :"david@127.0.0.1" == Node.self()
sentence = "The only time you run out of chances is when you stop taking them."
as_node(:david, phrase: sentence) do
assert :"david@127.0.0.1" = Node.self()
refute :"captain@127.0.0.1" == Node.self()
assert ^phrase = David.talk()
foo = :bar
refute match?(%{node: ^foo}, %{node: :foo})
end
end
end
See full example.
Enjoy the package! I would love to receive a shoutout and/or your feedback 
First Post!
archan937
I just released ExUnited v0.1.1 containing the following enhancements:
- Add
:excludeoption for individual spawned nodes - Exclude current project as dependency (instead, add “lib” to code paths)
- Do not generate config files
- Fix redundant prompt when in verbose mode
Popular in Libraries
As the title states, EctoEnum has just been updated after some time of hardly any activity in the repo. Here’s the latest release: https:...
New
Hi all!
I’m happy to announce that Telemetry v0.3.0 is out! This release marks the conversion from Elixir to Erlang so that all the libr...
New
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
Hello there,
I would like to share a feature toggles library (AKA feature flags) I’ve been working on.
The main package is FunWithFlags...
New
Hey all,
We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3!
We have successfully on-boarded the full suite of integration tests (...
New
Presenting Aviacommerce, open source e-commerce platform in Elixir
Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
LiveMotion enables high performance animations declared on the server and run on the client.
As a follow up to my previous thread A libr...
New
PhoenixWS - Websockets over Phoenix Channels
Source code on Github here: https://github.com/tmbb/phoenix_ws
Phoenix channels are a great...
New
I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process managemen...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
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
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
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New







