EUnit is a Lightweight Unit Testing Framework for Erlang
Questions tagged [eunit]
79 questions
10
votes
2 answers
EUnit output debug info from tested modules
Let us say I have a module called example.erl
In this module I use the following construct for debugging:
%%% Switch debugging output on/off:
%-define(DBG(Str, Args), ok).
-define(DBG(Str, Args), io:format(Str, Args)).
It helps me to output various…

skanatek
- 5,133
- 3
- 47
- 75
8
votes
1 answer
How do I skip an eunit test?
I wonder how to mark a specific test in eunit in a way that will force it to be ignored (ie compiled, but not executed) on the next test run. I'm asking this question in a TDD context, ie I'd like to refactor in the green, but still have some test…

jupp0r
- 4,502
- 1
- 27
- 34
8
votes
2 answers
How to do unit test coverage in Erlang
When using Python I do test code coverage with tools like python-coverage and especially for django the package djaango-nose, I'm looking for an equivalent in Erlang. I already do tests with eunit and generate my reports with surefire but I didn't…

Rodolphe
- 848
- 4
- 15
7
votes
3 answers
eunit: How to test a simple process?
I'm currently writing a test for a module that runs in a simple process started with spawn_link(?MODULE, init, [self()]).
In my eunit tests, I have a setup and teardown function defined and a set of test generators.
all_tests_test_() ->
…

jaw
- 932
- 2
- 10
- 24
7
votes
2 answers
Erlang EUnit test module that depends on a library application
I have a medium-sized release with a handful of applications. I recently refactored some common functionality out into a library application within the release. This made my EUnit tests fail with undef messages whenever testing anything that…

dantswain
- 5,427
- 1
- 29
- 37
7
votes
3 answers
Erlang YAWS: How to test a simple REST web service?
In a simple Erlang YAWS-based RESTful application I would like to have a set of tests that send HTTP requests to a RESTful API, get responses from the server and then test those responses.
It would be nice if each "send-request-get-request-test"…

skanatek
- 5,133
- 3
- 47
- 75
7
votes
4 answers
not output exception stack trace in EUnit
I'm write a test with EUnit, but not anything exception detail output in console.
exp_test() ->
?assertEqual(0, 1/0).
Run this module:exp_test() in the Erlang Shell output following
** exception error: bad argument in an arithmetic expression
in…

hpyhacking
- 285
- 3
- 14
6
votes
5 answers
Is there a way of only running unit tests in a single module using Eunit in Erlang/OTP?
I have a number of modules with unit tests. Is there a way of only running unit tests in a single module?
This is what the relevant section of the module looks like:
-export([ .....…

mbsheikh
- 2,501
- 5
- 23
- 33
6
votes
3 answers
EUnit fails to test private functions
I'm writing EUnit tests for Erlang code.
I have a source module:
-module(prob_list).
-export([intersection/2,union/2]).
probability([], _Item) -> false;
probability([{First,Probability}|Rest], Item) ->
if
First == Item -> Probability;
…

Uko
- 13,134
- 6
- 58
- 106
6
votes
2 answers
Erlang, eunit and gen_server: context cleanup failed
I wrote some eunit test on my gen_server:
-module(st_db_tests).
-include_lib("eunit/include/eunit.hrl").
main_test_() ->
{foreach,
fun setup/0,
fun cleanup/1,
[
fun db_server_up/1
]}.
setup() ->
{ok,Pid} =…

Dmitrii Dushkin
- 3,070
- 4
- 26
- 37
6
votes
1 answer
How to debug my Eunit test suite run when using rebar3?
I have created an release app with rebar3 (beta-4).
Added some eunit tests and wrote some code.
For now I have to debug one test case to see what I have to add to make the implementation to work properly.
I found some articles about using dbg from…

Stanislav Trifan
- 144
- 10
6
votes
3 answers
Getting test results from Eunit in Erlang
I am working with Erlang and EUnit to do unit tests, and I would like to write a test runner to automate the running of my unit tests. The problem is that eunit:test/1 seems to only return "error" or "ok" and not a list of tests and what they…

Zachary K
- 3,205
- 1
- 29
- 36
5
votes
2 answers
A common setup and teardown method for Erlang Eunit test suites
I am trying to check if all the indexes I have defined in MongoDB are being used by my application and that there are no extra indexes. I have a utility that does that for a single Eunit test suite. However, some of my components have more than one…

Vishal
- 1,169
- 2
- 12
- 20
5
votes
4 answers
Showing full expected and value information when ?_assertEqual fails
I'm coding a unit test where a (rather lengthy) binary is generated, and I want to assert that the generated binary equals the one I expect to be generated. I'm running eunit through "rebar eunit".
Thing is, when this assertion fails, the output is…

marcelog
- 7,062
- 1
- 33
- 46
4
votes
1 answer
What's the point of meck:validate?
As a newcomer to meck, I've been putting together a test that shows the various features. I cannot, however, understand why a developer might call meck:validate. Here's my…

MrBlueSky
- 728
- 6
- 20