Questions tagged [eunit]

EUnit is a Lightweight Unit Testing Framework for Erlang

79 questions
2
votes
1 answer

How to not symlink the priv directory for Rebar3 eunit tests?

When using: $ rebar3 as test eunit it compiles the code into ebin, but the other directories are symlinked in the _build/test/lib folder. I've tried using profile test by modifying: {relx, [{dev_mode, false}]} This works only for _build/test/rel…
casillic
  • 1,837
  • 1
  • 24
  • 29
2
votes
1 answer

SonarQube code coverage for Erlang EUnit tests

I am using Maven to run EUnit tests on my Erlang project and then making a static code analysis. I do not know how to configure the coverage report path so that SonarQube could also show my code coverage results.
Ayaz Farooq
  • 273
  • 3
  • 7
2
votes
1 answer

More human-readable tests messages with Erlang EUnit?

I am used to JavaScript testing, especially its BDD frameworks and libraries like Chai where I can describe tests in a human-readable manner and name tests with strings, e.g. "UserProfile -> Update First Name", then see these message as the output…
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
2
votes
2 answers

Why does Eunit not require test functions to be exported?

I'm going through the EUnit chapter in Learn You Some Erlang and one thing I am noticing from all the code samples is the test functions are never declared in -export() clauses. Why is EUnit able to pick these test functions up?
KallDrexx
  • 27,229
  • 33
  • 143
  • 254
2
votes
2 answers

How to test gen_server internal state with eunit

Is it possible to inspect the internal state of a gen_server after a callback function has been called? I would rather not change the API of my server here.
Rich Ashworth
  • 1,995
  • 4
  • 19
  • 29
2
votes
1 answer

Is it considered good practice to include EUnit tests within an Erlang module?

There seem to be two common approaches to using EUnit: Include the tests themselves at the end of a module Add the tests to a separate 'test' path Assuming I am only interested in testing the exported functions of a particular module, is there…
Rich Ashworth
  • 1,995
  • 4
  • 19
  • 29
2
votes
2 answers

Displaying EUnit code coverage in Emacs

I am using Rebar to build my erlang project and want to integrate it more tightly with Emacs. I found that if I add {cover_print_enabled, true}. to my rebar config file I get code coverage in the build output. However there is also an option…
Zachary K
  • 3,205
  • 1
  • 29
  • 36
2
votes
2 answers

rebar compile eunit error

I user rebar to make a eunit test with command "rebar compile eunit",but get a error info: ==> myapp (compile) ==> myapp (eunit) src/myapp_app.erl:8: badly formed 'include_lib' src/myapp_app.erl:26: undefined macro 'assertNot/1' ERROR: eunit…
2
votes
2 answers

Why does EUnit compile .beam files into .eunit/ebin?

Disclaimer: The author of this question has mostly theoretical knowledge of Erlang/OTP. I have a small OTP application which calls some non-Erlang executable inside the myapp/ebin directory via open_port(). When I run the application itself…
skanatek
  • 5,133
  • 3
  • 47
  • 75
1
vote
1 answer

eunit test for timeout

How can I test that a gen_fsm does indeed timeout with eunit? {ok, GH} = gen_fsm:start_link(myFSM, [], []), //after 15 sec it should timeout if no messages received. //What must I write here to test it?
Daniel
  • 20,420
  • 10
  • 92
  • 149
1
vote
1 answer

Build rabbitmq-server and erlang with FIPS enabled from source

I'm trying to install rabbitmq-server on Ubuntu 20.04 with FIPS enabled, and I saw that erlang DEB default packages doesn't have it compiled in them. I read this guide - https://www.erlang.org/doc/apps/crypto/fips.html and built erlang from source…
Learner
  • 198
  • 6
1
vote
2 answers

In Erlang's EUnit, assert that a function was called with an anonymous function

I have some code that looks like this: -module(ca_data). -export([delete_ca_data/1]). % ... delete_ca_data(N) when N < 1 -> ?NEGATIVE_ID_ERROR; delete_ca_data(N) -> util_db_generic:delete_object(ca_data, N, fun(_) -> ok end). % ... And I have…
distortedsignal
  • 370
  • 5
  • 17
1
vote
1 answer

rebar eunit can't find include lib in erlang:latest docker container

I'm new to docker and erlang. I've installed docker and VSCode on my windows machine and I want to learn to develop erlang in the container, so I created Dockerfile: FROM erlang:latest WORKDIR /project COPY . . and .devcontainer directory…
AndreyKo
  • 1,421
  • 2
  • 11
  • 25
1
vote
1 answer

Why is Eunit insisting my function is returning {ok, value} when it's not?

I'm doing something very simple: Reversing a list in Erlang without using BIFs. Here's my attempt: %% ----------------------------------------------------------------------------- %% Reverses the specified list. %% reverse(List) where: %% *…
Novicegrammer
  • 222
  • 1
  • 9
1
vote
1 answer

Why am I getting error while running a eunit test?

I am new to erlang and while learning I was trying to test the code written for Reverse Polish Notation Calculator. I have kept the test function written in a test file and then using the command "eunit:test(calc1,[verbose)], I get the…
Loki
  • 11
  • 1