Skip to content

A utility module that helps you iterate faster on unit tests.

License

Notifications You must be signed in to change notification settings

Olshansk/test_iex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestIex

A utility module that helps you iterate faster on unit tests.

This module lets execute specific tests from within a running iex shell to avoid needing to start and stop the whole application every time.

Background

Mix gives you several different options to run tests (show below).

All tests

  $ mix test

A specific file

  $ mix test ./path/test/file/test_file_test.exs

A specific test

  $ mix test ./path/test/file/test_file_test.exs:<line_number>

Motivation

The above commands, along with various options available by mix, make test driven development quick and easy. However, as a project grows, the process of starting and shutting down the application may take dozens of seconds, or even minutes. TestIex can help avoid spending those unnecessary seconds waiting for your application to start up every time.

Usage

Setup

  1. Start an iex session in the test environment
$ MIX_ENV=test iex -S mix
  1. Execute the start testing command
iex> TestIex.start_testing()
  1. Load Helpers. By default, TestIex loads the helper located under test/test_helper.exs. Additional helpers can be loaded like so:
iex> TestIex.load_helper(test/test_helper.exs)

Test Execution

Run a single test

iex> TestIex.test("./path/test/file/test_file_test.exs", line_number)

Run all the tests in a specific file

iex> TestIex.test("./path/test/file/test_file_test.exs")

Run multiple whole test files

iex> TestIex.test(["./path/test/file/test_file_test.exs", "./path/test/file/test_file_2_test.exs"])

Code Iteration

While your iex session is active, you may want to modify part of your source code and re-execute the test. Simply recompute the module modified, or the whole project, and rerun the TestIex.test function.

Single module

iex> r MyModulesNameSpace.MyModule

Whole project

iex> recompile

Publishing New Package Versions

For library maintainers, the following is an example of how to publish new versions of the package. Run the following commands assuming you incremented the version in the mix.exs file from 0.3.4 to 0.3.5:

git commit -am "Increase version from 0.3.4 to 0.3.5"
git tag -a v0.3.5 -m "Git tag 0.3.5"
git push origin --tags
mix hex.publish

About

A utility module that helps you iterate faster on unit tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages