eunit(3)

πŸ“¦
version 29.0.6 Β· 2 versions
, in nixos 26.05, nixpkgs unstable, ubuntu stonking

πŸŽ€ 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 to true, 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 variable EUNIT are also included last in the option list β€” meaning they have lower precedence than the ones you put in Options. So your Options win 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