erlangejabberdeunit

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,
             {"ody-staging-chatapi.toprpggame.com",80},
             "/",[],post,{...},...}},
     infinity]}}

I googled and found that we have to start inets like inets:start() and I placed that in my setup function but that did not solve the problem. Is there anything Im missing. Basically, Im calling httpc:request in my test and so the error.

Thanks for any inputs.


Solution

  • To put it simply, you can do two kinds of tests in Erlang. First is the unit tests, which is accomplished by eunit, and the second one is integration (or black box) tests with the help of common tests.

    For eunit, it's best to mock external or 3rd party dependent calls (or libs) to get the best coverage, and so your tests will be consistent. Here's an example.

    If you want to do external calls, I suggest to do it in integration tests instead.