hst337

hst337

MixTester - tiny tool for testing mix tasks and any other project management tools

MixTester

This is a tiny tool I’ve developed during implementation of incremental compilation for my optimizing compiler. MixTester’s primary goal was to provide very simple and handy helpers for mix project initialization and project management in test environment.

Docs
Github

Features

  • 100% documented
  • Real mix project management experience with new flags and other stuff
  • Application env configuration
  • Dependency list and other mix.exs configuration
  • Handy and simple helpers for common commands
  • ExUnit’s async friendly

Example:

defmodule AwesomeTask do
  use ExUnit.Case, async: true

  setup do
    deps = [ {:awesome_task, path: File.cwd!()} ]
    configuration = %{{:awesome_task, :year} => 2007}

    # Creates project with `mix new my_project --sup`
    # Which has `awesome_task` as a dependency
    # And configuration where `config.exs` has
    project =
      MixTester.setup(
        name: "my_project",
        new: "--sup",
        application_env: %{
          "config" => configuration
        },
        project: [
          deps: deps
        ]
      )

    # Creates the test file
    MixTester.write_ast(project, "test/my_project_test.exs", quote do
      defmodule MyProjectTest do
        use ExUnit.Case, async: true

        test "Just works" do
          assert 2007 == AwesomeModule.what_year_is_today()
        end
      end
    end)

    # Cleanup the tmp dir
    on_exit(fn -> MixTester.cleanup(project) end)
    {:ok, project: project}
  end

  test "My awesome task", %{project: project} do
    # Run the task we are testing
    assert {_, 0} = MixTester.mix_cmd(project, "awesome")

    # Run the test written above and check if it's run successfully
    assert {_, 0} = MixTester.mix_cmd(project, "test")
  end
end

Where Next?

Popular in Announcing Top

asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ab...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: GitHub - devonestes/assertions: Helpful a...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
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 12560 134
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
benlime
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
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10858 107
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement