Elixir Library for carefully refactoring critical paths, influenced heavily by [github/scientist](https://github.com/github/scientist).
(this is in an unfinished stage, as we flesh out the design of Experiment)
Running Elixir in production? ExUnit says all your tests pass? Can't wait to be
utilizing the awesome hot-code reloading feature to push up your new changes?
Well, hold on there, for critical parts of your application you may need more
Experiment allows you to run refactored code side-by-side with your previously
written code, compare the outputs of each, and notifying when something didn't
return as expected.
Let's say you're refactoring a super important controller. Tests can help, but
sometimes you really want to pit your refactored code against your current code.
defmodule App.ImportantAPIController do
def index(conn, params) do
Experiment.new("returns widget for rendering")
|> Experiment.test(&func_to_experiment/1, ["foo"])
render conn, widget: widget
def func_to_experiment(type) do
def another_func_to_experiment do
def func_that_works do
# Override default behavior which `==` the control and candidate.
def custom_compare_tests(control, candidate) do
control.type == candidate.type
You can define your own Experiment adapter for recording results by using the `Experiment.Base` module.
defmodule App.ExperimentAdapter do
def record(%Experiment.Lab = lab, control_result, candidate_result) do
# Do something with the results, save them to the DB, etc.
In your config, you can specify your own Experiment adapter.