eunit

how to use rebar to create an erlang module with an eunit test?

我与影子孤独终老i 提交于 2019-12-25 09:42:38
问题 My goal is quite simple; while I am learning Erlang, I would like to use rebar to create a basic module with an eunit test: I have tried the following: mkdir erlangscratch cd erlangscratch rebar create template=simplemod modid=erlangscratch Edit the 'test/erlangscratch_tests.erl' to look like this: -module(erlangscratch_tests). -include_lib("eunit/include/eunit.hrl"). % This should fail basic_test_() -> ?assert(1 =:= 2). Execute the tests: snowch@tp:~/erlangscratch$ rebar co eu ==>

how to use rebar to create an erlang module with an eunit test?

六月ゝ 毕业季﹏ 提交于 2019-12-25 09:42:10
问题 My goal is quite simple; while I am learning Erlang, I would like to use rebar to create a basic module with an eunit test: I have tried the following: mkdir erlangscratch cd erlangscratch rebar create template=simplemod modid=erlangscratch Edit the 'test/erlangscratch_tests.erl' to look like this: -module(erlangscratch_tests). -include_lib("eunit/include/eunit.hrl"). % This should fail basic_test_() -> ?assert(1 =:= 2). Execute the tests: snowch@tp:~/erlangscratch$ rebar co eu ==>

What's the point of meck:validate?

亡梦爱人 提交于 2019-12-23 15:56:42
问题 As a newcomer to meck, I've been putting together a test that shows the various features. I cannot, however, understand why a developer might call meck:validate. Here's my example: -module(meck_demo). -include_lib("eunit/include/eunit.hrl"). validate_is_of_limited_use_test_() -> { foreach, fun setup_mock/0, fun cleanup_mock/1, [fun validate_does_not_fail_if_a_function_is_not_called/0, fun validate_does_not_fail_if_a_function_is_called_with_wrong_arity/0, fun validate_does_not_fail_if_an

Showing full expected and value information when ?_assertEqual fails

╄→尐↘猪︶ㄣ 提交于 2019-12-22 06:45:06
问题 I'm coding a unit test where a (rather lengthy) binary is generated, and I want to assert that the generated binary equals the one I expect to be generated. I'm running eunit through " rebar eunit ". Thing is, when this assertion fails, the output is abreviated with " ... ", and I want to see the complete output so I can spot where the difference is. I'm now using " ?debugFmt() " as a temporary solution, but I'd like to know if there's an alternative to it (a config option or argument

How to use Eunit:test() generate a xml file which include some compling info

荒凉一梦 提交于 2019-12-12 02:08:18
问题 I have some erlang file(.erl).And I compile them. Now I want to use some function to generate a xml which is about the compling info of these files. Here is a address, http://www.erlang.org/doc/apps/eunit/eunit.pdf In this pdf,There is a function eunit:test/2 which can generate a xml file. eunit:test([fib, eunit_examples], [{report,{eunit_surefire,[{dir,"."}]}}]). But i don't know these parameters represent. I just know fib = modulename dir = generate location.What about eunit_examples?

More human-friendly tests messages with Erlang EUnit?

拟墨画扇 提交于 2019-12-11 06:59:35
问题 I am used to JavaScript testing, especially its BDD frameworks and libraries like Chai where I can describe tests in a human-friendly manner and name tests with strings, e.g. "UserProfile -> Update First Name", then see these message as the output when running tests. Is it possible to write Erlang tests in a more natural way, or at least, integrate descriptions in to tests run process, not just have them as comments, but see the name of a test which failed? 回答1: Yes. To add descriptions to

How to debug erlang code during rebar3 eunit?

微笑、不失礼 提交于 2019-12-10 15:22:40
问题 I have created an release app with rebar3 (beta-4). Added some eunit tests and wrote some code. For now I have to debug one test case to see what I have to add to make the implementation to work properly. I found some articles about using dbg from erlang console and I found how to write debug info from eunit. But I need to get info from code that I have to test (the actual implementation(logic)). Is there a way to debug erlang code (actual source code, not the test one) when rebar3 is used

passing runtime arguments to erlang when running rebar eunit

大憨熊 提交于 2019-12-10 11:13:06
问题 In my startup script, I am starting erlang with: erl -args_file vm.args Currently, while trying to run unit tests with rebar eunit is there a way for me to pass custom runtime arguments such as the -args_file option to the erlang process that rebar kicks off? I have searched docs high and low to no avail... I appreciate the help. 回答1: I answered my own question. I use the ERL_FLAGS variable to pass command line args. Here is a snippet from my Makefile: ERL_FLAGS="-args_file test/conf/vm.eunit

passing runtime arguments to erlang when running rebar eunit

Deadly 提交于 2019-12-06 07:35:00
In my startup script, I am starting erlang with: erl -args_file vm.args Currently, while trying to run unit tests with rebar eunit is there a way for me to pass custom runtime arguments such as the -args_file option to the erlang process that rebar kicks off? I have searched docs high and low to no avail... I appreciate the help. I answered my own question. I use the ERL_FLAGS variable to pass command line args. Here is a snippet from my Makefile: ERL_FLAGS="-args_file test/conf/vm.eunit.args" ./rebar skip_deps=true eunit The first method is satisfied with your restriction: 1. in your eunit

Showing full expected and value information when ?_assertEqual fails

谁都会走 提交于 2019-12-05 11:28:02
I'm coding a unit test where a (rather lengthy) binary is generated, and I want to assert that the generated binary equals the one I expect to be generated. I'm running eunit through " rebar eunit ". Thing is, when this assertion fails, the output is abreviated with " ... ", and I want to see the complete output so I can spot where the difference is. I'm now using " ?debugFmt() " as a temporary solution, but I'd like to know if there's an alternative to it (a config option or argument somewhere that can be applied to " ?_assertEqual() " so the output is only shown when the assertion fails).