My eunit code xyz_test_()
has many lines of code. For example, it calls a function to find out the expected reply, before comparing it with the actual reply using the ?assertEqual macro.
I have tried to add io:fwrite inside the eunit code for debugging. But I do not see any output written by io:fwrite. What could be the reason?
I have put an example code below.
-module(my_sort).
-export([sort/1]).
-include_lib("eunit/include/eunit.hrl").
-spec sort([T]) -> [T].
sort([]) -> [];
sort([P|Xs]) ->
sort([X || X <- Xs, X < P]) ++ [P] ++ sort([X || X <- Xs, P < X]).
sort2_test_() ->
[ {"testcase with 4 paras", fun test_four/0},
{"testcase with 5 paras", fun test_five/0}].
test_four() ->
io:fwrite("Started test_4\n"),
[?_assertEqual([1,2,3,4], sort([3,1,4,2]))].
test_five() ->
io:fwrite("Started test_5\n"),
[?_assertEqual([1,2,3,4,5], sort([3,1,4,2,5]))].