Editing
ExUnit
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== ExUnit == [[File:Elixir_logo.png|thumb|right|150px|Elixir programming language logo]] [[ExUnit]] is the unit testing framework for the [[Elixir]] programming language. It provides a simple and flexible way to write, organize, and run tests in Elixir projects. With ExUnit, developers can verify the correctness of their code and ensure its reliability. === Features === ExUnit offers various features to simplify the unit testing process in Elixir: ==== Simple and Intuitive Syntax ==== ExUnit follows a simple and intuitive syntax, making it easy for developers to write tests. Its syntax resembles the familiar "assert" style found in many other programming languages. ==== Test Organization ==== Tests can be organized using modules and test cases. Modules group related tests together, allowing developers to organize their test suite in a logical and manageable manner. Test cases can be defined within modules using the `defmodule` and `deftest` macros, respectively. ==== Assertions ==== ExUnit provides a comprehensive set of assertions for verifying expected results. The available assertions include `assert`, `refute`, `assert_raise`, `assert_receive`, and many more. ==== Hooks ==== Hooks in ExUnit allow developers to set up and tear down test fixtures or perform other actions before and after tests. Hooks can be defined at the module or test case level using the `setup` and `teardown` callbacks. ==== Test Parallelization ==== ExUnit supports parallel execution of tests, enabling faster test runs by utilizing multiple CPU cores. Developers can configure the number of parallel processes to use in their test suite, enhancing overall testing efficiency. ==== Tagging ==== Tags can be assigned to tests, enabling selective test execution based on predefined criteria. This allows developers to group tests and run specific subsets based on tags, such as "integration", "performance", or any custom tags they define. === Usage === To use ExUnit, developers must first install the `ex_unit` package as a dependency in their Elixir project. Once installed, they can write tests by creating modules and test cases. Tests are defined as functions and can be run using the `mix test` command. Here is an example of a simple test case using ExUnit: ```elixir defmodule MyTest do use ExUnit.Case test "addition" do assert 2 + 2 == 4 end end ``` === Related Articles === * [[Elixir]] - The programming language ExUnit is built for. * [[Mix]] - The build tool used to compile and run ExUnit tests. * [[ExDoc]] - The Elixir documentation generator. * [[Phoenix Framework]] - A popular Elixir web framework with built-in support for ExUnit. == References == <references /> [[Category:Elixir (programming language)]] [[Category:Testing frameworks]] [[Category:Software testing tools]]
Summary:
Please note that all contributions to Elixir Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Elixir Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information