hst337

hst337

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? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews