Questions tagged [eunit]

EUnit is a Lightweight Unit Testing Framework for Erlang

79 questions
4
votes
2 answers

Using meck to make multiple calls to the same method with the same arguments

I know that with ruby/rspec, you can do something like the following in order to receive different return values for the different calls made to the method: allow(double).to receive(:msg).and_return(value1, value2, value3) I've only been able to…
Tony Baik
  • 146
  • 11
3
votes
2 answers

How to setup tests with the appropriate code using rebar3?

I have created a simple application via rebar3 templates such as: apps/myapp/app/myapp_app.erl -module(myapp_app). -behaviour(application). -export([start/2, stop/1]). start(_StartType, _Params) -> ok. stop(_State) -> ok. I have written…
GlinesMome
  • 1,549
  • 1
  • 22
  • 35
3
votes
1 answer

Erlang rebar, kernel options

I am trying to write simple erlang application, using rebar as eunit test runner. Is there any way to redirect annoying log messages into file, without doing it programmatically? Without rebar I can say erl -kernel error_logger "{file,\"test.log\"}"…
Viacheslav Kovalev
  • 1,745
  • 12
  • 17
3
votes
1 answer

Ensure epmd started

I have an eunit test that generates a unique node name and starts distribution: {A,B,C} = now(), Nodename = list_to_atom(lists:flatten(io_lib:format( "test-~b-~b-~b@localhost", [A, B, C]))), {ok, _} = net_kernel:start([Nodename,…
legoscia
  • 39,593
  • 22
  • 116
  • 167
3
votes
2 answers

How to start lager before running eunit test with rebar

I want to start lager before any eunit test is executed so that I can see the log when the tests are actually run (I use the log for debugging purposes). However I have hundreds of tests (spread across multiple apps and modules) and I don't want to…
Svetlin Mladenov
  • 4,307
  • 24
  • 31
3
votes
2 answers

passing runtime arguments to erlang when running rebar eunit

In my startup script, I am starting erlang with: erl -args_file vm.args Currently, while trying to run unit tests with rebar eunit is there a way for me to pass custom runtime arguments such as the -args_file option to the erlang process that rebar…
jshadyjlo
  • 133
  • 7
3
votes
1 answer

Eunit error with multiple apps

I have the following directory structure: myapp ├── apps │   ├── myapp │   ├── myotherapp │   └── myapp_common ├── deps │   ├── cowboy ...... I run eunit using rebar as follows in the main myapp directory: ./rebar skip_deps=true eunit It correctly…
mbsheikh
  • 2,501
  • 5
  • 23
  • 33
2
votes
2 answers

How to integrate erlang unit tests in hudson?

I spent a bit time on this work item ( here , I called it work item ).--- How to integrate the erlang unit test in hudson? after doing some research, I felt I found the way to resolve this: basically, write the unit test code in erl files. (using…
user477928
  • 61
  • 2
  • 6
2
votes
1 answer

How to use debugMsg in eunit and how to print something within the eunit testing although the test times out

I try to get the following to work as described in the erlang eunit documentation: debugMsg(Text) Outputs the message Text (which can be a plain string, an IO-list, or just an atom). The result is always ok. I do however get the following when…
Piskator
  • 605
  • 1
  • 9
2
votes
1 answer

IntelliJ Erlang "Unresolved macros"

Setup: IntelliJ IDEA 2022.2.2 Erlang plugin 0.11.1144 SDK: Erlang OTP 25, erts-13.0 Project Imported: https://github.com/FlowForwarding/enetconf Issue: When I mouse over some macros, I get the message "Unresolved macros '?debugMsg'", "Unresolved…
Bhuvan
  • 370
  • 9
2
votes
1 answer

How do I disable the error logger in EUnit test cases?

When running an EUnit test that tests an application or starts and stops (or tests killing of) gen_server or supervisor processs, error logger outputs crash reports and other messages by default: $ rebar3 eunit …
Adam Lindberg
  • 16,447
  • 6
  • 65
  • 85
2
votes
2 answers

Print test fixture description in erlang eunit failure

Is there a way to print the test description of an erlang test generator that uses fixtures? Using a generator makes it tricky to tell what test is actually failing and printing the description would help…
Paul
  • 4,422
  • 5
  • 29
  • 55
2
votes
1 answer

How can I progressively set up a mock using Meck?

I would like to be able to progressively set up a mock (using Meck), so that expectations for different calls are set in different test setup functions. I thought merge_expects might do the trick. But I am seeing unexpected results:…
MrBlueSky
  • 728
  • 6
  • 20
2
votes
1 answer

Using Rebar3 Common Test does not find hrl files in the include folder but eunit does

Using rebar3 eunit it is able to handle -include("some_file.hrl") in the tests, but this doesn't work with rebar3 ct. For some reason when I use rebar3 ct it tries to compile my eunit tests and fails because it can't find the .hrl files used in the…
casillic
  • 1,837
  • 1
  • 24
  • 29
2
votes
2 answers

Multiple clauses in EUnit's assertMatch?

I am using Erlang's EUnit for unit testing an application. I want to assert that a certain test value is between 2 and 3. There's no built-in support for this, so I am trying to use a pair of guards, like this: myTestCase -> ?assertMatch({ok, V}…
Philip
  • 1,532
  • 12
  • 23