eunit(3)
π NAME π
okay so bestie, eunit β this module is the main EUnit user interface π
(this page lives in the Erlang Module Definition manual, section 3, iykyk).
β¨ DESCRIPTION β¨
ngl the original page is not giving much here β this section is straight-up empty, no cap π. All the actual tea is down in FUNCTIONS, so scroll on down, queen π.
πΈ FUNCTIONS πΈ
π start() -> term().
Starts the EUnit server π«Ά. But lowkey? You almost never need to call this yourself β it gets started automatically, so it's giving "backup dancer, not main character" energy β¨.
π stop() -> term().
Stops the EUnit server π. And again β normally you don't need to call this function either. She's just here in case π .
π test(Tests :: term(), Options :: [term()]) -> ok | error | {error, term()}.
This is THE one, the icon, the moment π. It runs a whole set of tests. The format of Tests is described in the section EUnit test representation of the overview π β go look at that if you wanna know the shapes it can take.
Example time, bestie:
eunit:test(fred)
That runs all tests in the module fred, and also any tests in the module fred_tests β if that module exists, that is π.
ngl the _tests auto-discovery is iconic but it can surprise you. Details below. π
π¦ Options π¦
verboseβ spills more details about the tests as they're running. Basically turning on the director's commentary π¬.print_depthβ the maximum depth to which terms get printed when there's an error. Deep terms? She stops digging at this point π³οΈ.exact_executionβ if this boolean flag is set totrue, the framework will not automatically execute tests found in the related module suffixed with"_tests"π€. And yes, that auto-behaviour might be unwanted if execution of modules found in a folder is ordered while it contains both source and test modules β messyyyy π.scale_timeoutsβ if this numeric value is set, timeouts get scaled accordingly β¨. Super useful when you're running a set of tests on a slower host π. Examples:{scale_timeouts,10}makes the timeouts 10 times longer, while{scale_timeouts,0.1}would shorten them by a factor of 10. Math queen π .
π¨ important little detail, no cap: options in the environment variableEUNITare also included last in the option list β meaning they have lower precedence than the ones you put inOptions. So yourOptionswin the argument, periodt π.
See also: test/1 π β yes there's a one-arg version, go check her out.
and that's the whole page, bestie π
This little legend is brought to you by Ericsson AB, rocking eunit version 2.11, and she ate that π
β¨. Now go run some tests, you got this π«ΆπΈπ¦
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms