0
Eunit不会等待接收,有没有什么特别的eunit。Eunit测试不会等待接收
-module (test_account).
-include_lib ("eunit/include/eunit.hrl").
-compile (export_all).
login_test() ->
{ok, Socket} = gen_tcp:connect("localhost", 5678,
[binary, {packet, 4}]),
RoleName = <<"abc">>,
LenRoleName = byte_size(RoleName),
Password = <<"def">>,
LenPassword = byte_size(Password),
LoginBin = <<11001:16, LenRoleName:16, RoleName/binary,
LenPassword:16, Password/binary>>,
gen_tcp:send(Socket, LoginBin),
print(Socket).
print(Socket) ->
receive
{tcp, Socket, Data} ->
io:format("Data=~p~n", [Data])
end.
如果我直接拨打test_account:login_test().
,可以收到回复。
谢谢。
谢谢,我要模拟一个tcp服务器。当配置设置装置时,有没有一种从应用程序的术语'env'中读取数据的好方法?否则,我必须在我的测试中对其进行硬编码。 – goofansu