Erlang eunit 测试已跳过(未更改代码!)
Erlang eunit test skipped (no code changed!)
我的测试失败了。我做了一些更改,取消了它们,运行 再次测试。我没有失败,而是得到了这个。
我的所有 .beam
文件都存在。我的 git status
没有显示任何变化。
=====================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
error
60> room:test().
=ERROR REPORT==== 14-Feb-2017::19:36:57 ===
** Generic server <0.1375.0> terminating
** Last message in was {join,#{auth => "auth",name => "Blandline"}}
** When Server state == {<0.1376.0>,<0.1379.0>,<0.1380.0>}
** Reason for termination ==
** {function_clause,
[{table,terminate,
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[{file,"table.erl"},{line,15}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,615}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]},
{<0.1376.0>,<0.1379.0>,<0.1380.0>}],
[{file,"table.erl"},{line,47}]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},
{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
room: firstMove_test...*skipped*
undefined
*unexpected termination of test process*
::{function_clause,[{table,terminate,
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[...]},
{gen_server,try_handle_call,4,...},
{gen_server,handle_msg,...},
{proc_lib,...}]},
{<0.1376.0>,<0.1379.0>,<0.1380.0>}],
[{file,"table.erl"},{line,47}]},
{gen_server,try_terminate,3,
[{file,"gen_server.erl"},{line,629}]},
{gen_server,terminate,7,
[{file,"gen_server.erl"},{line,795}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]}
=======================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
error
s:s 只是 gen_server:call
的快捷方式。我正在测试此模块中的其他模块。
-module(room).
-behaviour(gen_server).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
testRoom() ->
{ok, R} = room:go(),
{ok, T, _} = s:s(R, {join, #{name => "Blandline", auth => "auth"}}),
{ok, T, _} = s:s(R, {join, #{name => "Kreutzer", auth => "auth"}}),
{R, T}.
firstMove_test() ->
{R, T} = testRoom(),
{ok, #{actions := _, board := _, clock := _}} = s:s(R, {play, T, {take, x, {1,2}}, {"Blandline", "auth"}}).
badMove_test() ->
{R, T} = testRoom(),
{error, invalid_input} = s:s(R, {play, T, {take, x, {1,2,3}}, {"Blandline", "auth"}}).
badAuth_test() ->
{R, T} = testRoom(),
{error, invalid_auth} = s:s(R, {play, T, {take, x, {1,2}}, {"Blandline", "badauth"}}).
badTable_test() ->
{R, _} = testRoom(),
{error, bad_table} = s:s(R, {play, self(), {take, x, {1,2}}, {"Blandline", "badauth"}}).
如错误报告所述:
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[{file,"table.erl"},{line,15}]},
您在文件 table.erl 第 15 行中有一个不匹配的 case 子句:-)
我 认为 虽然您撤消了您的更改,但测试开始失败的原因是因为您 运行 从 Erlang shell 进行测试而且你有一些东西(比如 gen_server)仍然 运行ning 由于某些原因失败了。
换句话说,您的测试不可重复,因为它们要么没有正确拆除所有依赖项,要么因为它们需要像这样的外部依赖项 gen_server 在 Erlang 中手动启动 shell 在 运行 测试之前。
我强烈建议忘记 Erlang shell 到 运行 测试。使用 rebar3 从终端构建和 运行 测试。这将迫使您处理所有依赖项并进行可靠的测试。完成这项工作所花费的时间将得到充分利用:-)
我的测试失败了。我做了一些更改,取消了它们,运行 再次测试。我没有失败,而是得到了这个。
我的所有 .beam
文件都存在。我的 git status
没有显示任何变化。
=====================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
error
60> room:test().
=ERROR REPORT==== 14-Feb-2017::19:36:57 ===
** Generic server <0.1375.0> terminating
** Last message in was {join,#{auth => "auth",name => "Blandline"}}
** When Server state == {<0.1376.0>,<0.1379.0>,<0.1380.0>}
** Reason for termination ==
** {function_clause,
[{table,terminate,
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[{file,"table.erl"},{line,15}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,615}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]},
{<0.1376.0>,<0.1379.0>,<0.1380.0>}],
[{file,"table.erl"},{line,47}]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,629}]},
{gen_server,terminate,7,[{file,"gen_server.erl"},{line,795}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
room: firstMove_test...*skipped*
undefined
*unexpected termination of test process*
::{function_clause,[{table,terminate,
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[...]},
{gen_server,try_handle_call,4,...},
{gen_server,handle_msg,...},
{proc_lib,...}]},
{<0.1376.0>,<0.1379.0>,<0.1380.0>}],
[{file,"table.erl"},{line,47}]},
{gen_server,try_terminate,3,
[{file,"gen_server.erl"},{line,629}]},
{gen_server,terminate,7,
[{file,"gen_server.erl"},{line,795}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]}
=======================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
error
s:s 只是 gen_server:call
的快捷方式。我正在测试此模块中的其他模块。
-module(room).
-behaviour(gen_server).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
testRoom() ->
{ok, R} = room:go(),
{ok, T, _} = s:s(R, {join, #{name => "Blandline", auth => "auth"}}),
{ok, T, _} = s:s(R, {join, #{name => "Kreutzer", auth => "auth"}}),
{R, T}.
firstMove_test() ->
{R, T} = testRoom(),
{ok, #{actions := _, board := _, clock := _}} = s:s(R, {play, T, {take, x, {1,2}}, {"Blandline", "auth"}}).
badMove_test() ->
{R, T} = testRoom(),
{error, invalid_input} = s:s(R, {play, T, {take, x, {1,2,3}}, {"Blandline", "auth"}}).
badAuth_test() ->
{R, T} = testRoom(),
{error, invalid_auth} = s:s(R, {play, T, {take, x, {1,2}}, {"Blandline", "badauth"}}).
badTable_test() ->
{R, _} = testRoom(),
{error, bad_table} = s:s(R, {play, self(), {take, x, {1,2}}, {"Blandline", "badauth"}}).
如错误报告所述:
[{{case_clause,{ok,#{x => "Blandline"}}},
[{table,handle_call,3,[{file,"table.erl"},{line,15}]},
您在文件 table.erl 第 15 行中有一个不匹配的 case 子句:-)
我 认为 虽然您撤消了您的更改,但测试开始失败的原因是因为您 运行 从 Erlang shell 进行测试而且你有一些东西(比如 gen_server)仍然 运行ning 由于某些原因失败了。
换句话说,您的测试不可重复,因为它们要么没有正确拆除所有依赖项,要么因为它们需要像这样的外部依赖项 gen_server 在 Erlang 中手动启动 shell 在 运行 测试之前。
我强烈建议忘记 Erlang shell 到 运行 测试。使用 rebar3 从终端构建和 运行 测试。这将迫使您处理所有依赖项并进行可靠的测试。完成这项工作所花费的时间将得到充分利用:-)