2016-09-14 36 views
0
get_ue_supported_srvcc([]) -> 
    ?SRVCC_3GPP_NONE_SUPPORT; 
get_ue_supported_srvcc([#sip_contactV{extensionsP = EP} | T]) -> 
    case b2bLib:support_tags_to_value(EP) of 
    ?SRVCC_3GPP_NONE_SUPPORT -> 
     get_ue_supported_srvcc(T); 
    Flag -> 
     Flag 
    end. 

我想創建此功能的單元測試, 這裏是我的單元測試情況:如何對Erlang函數進行單元測試?

get_ue_supported_srvcc_test() -> 
    Contact = 
    [#sip_contactV{extensionsP = 
       [{"+sip.instance", 
      {quoted_string,"<urn:gsma:imei:35502406-005233-0>"}}, 
       {"+g.3gpp.icsi-ref", 
      {quoted_string,"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"}}, 
       "+g.3gpp.mid-call", 
       "+g.3gpp.srvcc-alerting", 
       "+g.3gpp.ps2cs-srvcc-orig-pre-alerting", 
       "video"]}], 

    ?assertEqual(7, b2bAtcfLib:get_ue_supported_srvcc(Contact)). 

但是當我運行它,我得到這個錯誤:

======================== EUnit ======================== 
module 'b2bAtcfLib' 
    b2bAtcfLib_tests: get_ue_supported_srvcc_test (module 'b2bAtcfLib_tests')...*failed* 
in function b2bLib:support_tags_to_value/1 
    called as support_tags_to_value([{"+sip.instance",{quoted_string,"<urn:gsma:imei:35502406-005233-0>"}}, 
{"+g.3gpp.icsi-ref", 
    {quoted_string,"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"}}, 
"+g.3gpp.mid-call","+g.3gpp.srvcc-alerting", 
"+g.3gpp.ps2cs-srvcc-orig-pre-alerting","video"]) 
in call from b2bAtcfLib:get_ue_supported_srvcc/1 (src/b2bAtcfLib.erl, line 1735) 
in call from b2bAtcfLib_tests:'-get_ue_supported_srvcc_test/0-fun-0-'/1 (test/unit/b2bAtcfLib_tests.erl, line 49) 
in call from b2bAtcfLib_tests:get_ue_supported_srvcc_test/0 
**error:undef 
    output:<<"">> 

    [done in 0.008 s] 
======================================================= 

錯誤意味着b2bLib:support_tags_to_value/1undef

的規定這個功能b2bLib:support_tags_to_value

support_tags_to_value(FieldStr) -> 
    lists:sum([Val || {Tag, Val} <- ?TAGLIST, lists:member(Tag, FieldStr)]). 
+0

您能否提供support_tags_to_value的輸出([{「+ sip.instance」,{quoted_string,「」}}, {「+ g.3gpp.icsi -ref「, {quoted_string,」urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel「}}, 」+ g.3gpp.mid-call「,」+ g.3gpp.srvcc-alerting「 , 「+ g.3gpp.ps2cs-srvcc-orig-pre-alerting」,「video」])。 – byaruhaf

回答

3

的錯誤是:

**error:undef 

這意味着測試呼叫,這不是定義的函數。無法找到該模塊,或者該模塊未定義具有該名稱和參數的功能。

整個錯誤信息有點混亂。現在我們知道,我們得到了一個「函數未定義」的錯誤,我們應該看這條線:

in function b2bLib:support_tags_to_value/1 

即使它說:「在」此功能發生錯誤,這是這是未定義功能。

所以無論是測試以這樣一種方式,它沒有找到b2bLib模塊或模塊不定義一個名爲support_tags_to_value帶一個參數的功能運行。如果是前者,則將-pa path/to/ebin添加到Erlang命令行中,以便將正確的目錄添加到代碼路徑中。

相關問題