EUnit is a Lightweight Unit Testing Framework for Erlang
Questions tagged [eunit]
79 questions
1
vote
1 answer
Set the mnesia directory with rebar running eunit test
I am using rebar, and I need to set the mnesia directory for my Erlang eunit tests (which you can usually do by doing erl -mnesia dir DIRECTORY at the cmdline). How do I run eunit tests with a special mnesia dir with rebar?
I do not think that the…

Johnny Test
- 107
- 1
- 7
1
vote
1 answer
Erlang - Eunit setup function doesn't run
I would like to write tests, where setup and cleanup functions don't execute for every single test, but once - at the start of testing and at the end of testing.
So i tried this way:
generator_test_() ->
{setup, fun setup/0, fun cleanup/1,
…

otisonoza
- 1,334
- 2
- 14
- 32
1
vote
3 answers
How do I use Vim with Rebar
Trying to get up and running Vim + Rebar.
Separately they work but not together. What I want to achieve is to run eunit without leaving the Vim.
I guess this is doable with following plugin https://github.com/mbbx6spp/vim-rebar . Unfortunately is…

ruslander
- 3,815
- 4
- 32
- 34
0
votes
1 answer
eunit testing for sent messages
I am trying to write eunit tests to check wether a module send messages as it should. I can pass a PID as parameter so that it sends the messages to the testing module. The problem is that it sends messages using gen_fsm:send_event.
I have tried…

Daniel
- 20,420
- 10
- 92
- 149
0
votes
1 answer
EUnit view failed test results in detail
I am not an expert in EUnit and I mainly use ?assert_(fun1(Args) == Result) to test all the functions in my Erlang code (I define Result in the _tests module).
But in case a test fails it does not show what fun1 has actually returned.
Instead, it…

skanatek
- 5,133
- 3
- 47
- 75
0
votes
1 answer
How to use Eunit:test() generate a xml file which include some compling info
I have some erlang file(.erl).And I compile them. Now I want to use some function to generate a xml which is about the compling info of these files.
Here is a address,
http://www.erlang.org/doc/apps/eunit/eunit.pdf
In this pdf,There is a function…

yiwei
- 1
0
votes
1 answer
gen_server stop badmatch on sub process stopped
I have a table process which creates a pidfor a board as part of its state with go().
I am testing that terminating the table also terminates the board. But the board is not stopping as expected.
My test:
kills_board_test() ->
{ok, Table} =…

quantumpotato
- 9,637
- 14
- 70
- 146
0
votes
1 answer
Unable to use httpc module in my eunit test erlang.!`
Im writing my first test using enit in erlang. I managed to make some progress except that Im facing this error
exit:{noproc,
{gen_server,call,
[httpc_manager,
{request,
{request,undefined,<0.1634.0>,0,http,
…

sad
- 820
- 1
- 9
- 16
0
votes
0 answers
Is there a way to call application:set_env in an eunit test?
Is it possible in an eunit test to set an environment variable used in the code under test? This fails with **error:undef:
example_test() ->
application:set_env(an_app, example_key, "value").
Edit:
There's not much to show for the error, but…

Don Branson
- 13,631
- 10
- 59
- 101
0
votes
1 answer
Rebar eunit runs non native (non Hipe) code
I have compiled my Erlang module using
rebar compile
using the following option in rebar.config
{erl_opts, [native, {hipe, [verbose]}, warnings_as_errors, debug_info]}.
{eunit_compile_opts, [native, {hipe, [verbose]}, warnings_as_errors,…

Vishal
- 1,169
- 2
- 12
- 20
0
votes
2 answers
What is preferred way to add setup and teardown methods in an eunit test fixture?
So I want to add a method that is executed before all other tests, and another that is executed when all tests have finished, for example:
test_setup() -> {whatever}.
test_teardown(_) -> {whatever}.
I know I can "manually" do this by explicitly…

level20dm
- 176
- 1
- 1
- 5
0
votes
1 answer
how to use rebar to create an erlang module with an eunit test?
My goal is quite simple; while I am learning Erlang, I would like to use rebar to create a basic module with an eunit test:
I have tried the following:
mkdir erlangscratch
cd erlangscratch
rebar create template=simplemod modid=erlangscratch
Edit…

Chris Snow
- 23,813
- 35
- 144
- 309
0
votes
4 answers
Examples of using Eunit to test clustered application
I find the documentation on Eunit lacking, with regards to how to test a multi-node application. I found this example, but sadly when I run:
cluster_test_() ->
{node, foo,
fun (Node) ->
[?_assertEqual(pong, net_adm:ping(Node))]
…

theburningmonk
- 15,701
- 14
- 61
- 104
0
votes
1 answer
erlang: automatically launch/stop applications for tests
have some function which performs html parsing of some content from web page.
I want to write some set of tests for it. In tests I'm going to fetch html content via httpc:request and pass it to my function with result validation in the end. But…

Anton Koval'
- 4,863
- 5
- 31
- 44
0
votes
1 answer
Start dependent application with eunit
I start lager as a dependent application when I run a unit test but for some reason the code under test does not see it.
-module(main_tests).
-include_lib("eunit/include/eunit.hrl").
main_test_() ->
{foreach,
fun distr_setup/0,
fun…

ruslander
- 3,815
- 4
- 32
- 34