Questions tagged [eunit]

EUnit is a Lightweight Unit Testing Framework for Erlang

79 questions
1
vote
1 answer

How do I meck the same function with multiple sets of parameter values?

I'm trying to meck out a call to application:get_env, but I'm testing a function that calls it with two different sets of arguments. I setup two separate meck:expect calls like this, but when the function I'm testing tries to call…
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
1
vote
1 answer

Testing a gen_server module using Common Test

I have this (very simple) gen_server implementation: -module(rand_gen). -behaviour(gen_server). -define(BASE, 1000). %% Module Functionality -export([start/0]). -export([stop/1]). -export([uniform/1, uniform/2]). %% Callback…
x80486
  • 6,627
  • 5
  • 52
  • 111
1
vote
1 answer

Error Report from a terminated process (expected to be normal)

I have a test module that tests my Table module. My Table module, when it terminates, calls this: terminate(_, State = {Board, Status, Players}) -> gen_server:stop(Board), ...stopping other processes, io:format("Table Terminating.~p~n",…
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
1
vote
1 answer

Erlang eunit test skipped (no code changed!)

I had a failing test. I made some changes, undid them, run my test again. Instead of failing, I get this. All of my .beam files are present. My git status shows no changes. ===================================================== Failed: 0. Skipped:…
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
1
vote
1 answer

Prevent eunit from timing out when running Triq tests

How can I change the timeout for the eunit in rebar3 config? My eunit runner is timing out when I run property-based Triq tests: ===> Verifying dependencies... ===> Compiling ierminer ===> Performing EUnit tests... Pending: …
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
1
vote
0 answers

Is there a way to make EUnit not bomb on gen_server exit (and consider it a failure)?

I have several EUnit tests to test functionality of a gen_server I have created. For example, let's take the following test for an IRC server I am writing: empty_channel_details_when_getting_details_of_channel_that_does_not_exist_test() -> …
KallDrexx
  • 27,229
  • 33
  • 143
  • 254
1
vote
2 answers

Where to put test file for eunit?

I'm trying to test function that loads file from disk and do some manipulation on it. I have my project divided into src/ and test/ directories. I put test file under test/ directory and tried to run unit test that loads this file. However file…
slakomy
  • 323
  • 1
  • 5
  • 18
1
vote
1 answer

Eunit assertions error reporting the wrong module

I started writing some functions to help test assertions on maps. Let's say I have the following map: #{a => 0, b => 2} And after calling a function in my business logic I expect the map to look like this: #{a => 1, b => 2} In other words, I…
egbokul
  • 3,944
  • 7
  • 36
  • 54
1
vote
1 answer

eunit Test suite was cancelled error

I have been trying to use IntellijIdea for erlang development. I created a project from existing sours using rebar. But when I try to run test cases I get following error. This is what I see on console /usr/lib/erlang/bin/erl -pa…
1
vote
3 answers

How to start application before all eunit cases

My Erlang project managed by rebar, it divides to different module. -pro |-- rel |-- src |-- test |--- module1_tests.erl |--- module2_tests.erl and for each module*_tests.erl, Use Eunit Fixtures to setup environment. For…
linbo
  • 2,393
  • 3
  • 22
  • 45
1
vote
1 answer

Any best practice around having different data in /priv for testing vs production?

I'm writing tests with EUnit and some of the Units Under Test need to read a data file via file:consult/1. My tests make assumptions about the data that will be available in /priv, but the data will be different in production. What's the best way to…
Gus
  • 1,132
  • 13
  • 21
1
vote
1 answer

Rebar eunit skips all app tests if root app is not included

my problem is that I can't run eunit tests for a single app or module without including the root app. My directory laylout looks a bit like this: ├── apps │   ├── app1 │   └── app2 ├── deps │   ├── amqp_client │   ├── meck │   ├── rabbit_common │  …
jaw
  • 932
  • 2
  • 10
  • 24
1
vote
2 answers

Dets leaves open process when test fails with EUnit

I have been playing with EUnit, it is nice but I'm running into issue with dets, when my test failed and haven't properly closed dets, the file is still open in my shell and I cannot close it because it was created by another process(when i ran…
Martin Bodocky
  • 651
  • 1
  • 5
  • 16
1
vote
1 answer

How do I test gen_events in erlang?

Most of my code looks like this handle_event({publish,Publish_Msg,Publishing_Channel},State)-> Member = pg2:get_members(helpers:get_channel_name(Publishing_Channel)), case Member of [M|O]-> [Pid!{send,Publish_Msg}||Pid<-[M|O]]; …
Akshat Jiwan Sharma
  • 15,430
  • 13
  • 50
  • 60
1
vote
1 answer

EUnit basic issues with generator

I am doing a basic test with EUnit : setup() -> [1, 2]. teardown(_) -> ended. success([H, T]) -> ?_assert(H =:= 1), ?_assert(H =:= 2), foo. setup_test_() -> {setup, fun setup/0, fun teardown/1, fun success/1}. And I don't…
Simon
  • 2,067
  • 2
  • 17
  • 30