???????????
rebar eunit
==> rebar_mix_test (eunit)
mix_worker_tests: add_test (module 'mix_worker_tests')...*failed*
in function mix_worker_tests:add_test/0 (test/mix_worker_tests.erl?? line 7)
**error:{badmatch??{error??{"no such file or directory"??"rebar_mix_test.app"}}}
output:<<"">>
=======================================================
Failed: 1.  Skipped: 0.  Passed: 0.
ERROR: One or more eunit tests failed.
ERROR: eunit failed while processing /Users/zhuoyikang/source/services/rebar_mix_test: rebar_abort
???????????????????erlang???????????????????????eunit?????????????????????????д??
??????????????e?????????д?Щ???????????otp?????????????????????Щ???????????????????????????????rebar eunit??У??????????????????У?????????
????????????????????????????????eunit??????????
??????ε????????????????????erlang?????????????erlang??????????????????????????????elixir/mix??
???????mix ??????ò???д????????
????elixir/mix???????????????д????????????????mix?????????????
rebar_mix_test cd ..
services mix new rebar_mix_test
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/rebar_mix_test.ex
* creating test
* creating test/test_helper.exs
* creating test/rebar_mix_test_test.exs
Your Mix project was created successfully.
You can use "mix" to compile it?? test it?? and more:
cd rebar_mix_test
mix test
Run "mix help" for more commands.
services cd rebar_mix_test
ls
README.md config    ebin      lib       mix.exs   src       test
??????е??????
mix test
Compiled src/rebar_mix_test_app.erl
Compiled src/rebar_mix_test_sup.erl
Compiled src/mix_worker.erl
Compiled lib/rebar_mix_test.ex
Generated rebar_mix_test app
Consolidated Collectable
Consolidated List.Chars
Consolidated String.Chars
Consolidated Enumerable
Consolidated IEx.Info
Consolidated Inspect
.
Finished in 0.1 seconds (0.1s on load?? 0.00s on tests)
1 test?? 0 failures
Randomized with seed 193760
????????????????demo????????????£?
????defmodule RebarMixTestTest do
????use ExUnit.Case
????doctest RebarMixTest
????test "the truth" do
????assert 1 + 1 == 2
????end
????end
????????:
????defmodule RebarMixTestTest do
????use ExUnit.Case
????doctest RebarMixTest
????test "the add" do
????assert :mix_worker.add(1??1) == 2
????end
????end
?????????????mix.ex????????У?mod: {:rebar_mix_test_app?? []}??
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[
mod: {:rebar_mix_test_app?? []}??
applications: [:logger]
]
end
???????????????????????????У?????Elixir????erlang???????????????????:????????????????????????????д??otp???rebar_mix_test??
??????????mix test????????
mix test
Compiled lib/rebar_mix_test.ex
Generated rebar_mix_test app
Consolidated List.Chars
Consolidated Collectable
Consolidated String.Chars
Consolidated Enumerable
Consolidated IEx.Info
Consolidated Inspect
.
Finished in 0.04 seconds (0.04s on load?? 0.00s on tests)
1 test?? 0 failures
Randomized with seed 55281??
????Elixir??ExUnit
????ExUnit??Elixir????????????????????СС??????????????????????????????callback?????
????????????????????????????????????????Щ??????????????????????????????????????????Щ??????????????д??????eunit??????????????
???????ò???????????????????????????磺
????a_test() ->
????{ok??Pid} =  KV.Registry.start_link(context.test)
????... do some logic with pid .
????ok.
????b_test() ->
????{ok??Pid} =  KV.Registry.start_link(context.test)
????... do some logic with pid .
????ok.
????...
????????ExUnit???????????д:
defmodule KV.RegistryTest do
use ExUnit.Case?? async: true
setup do
{:ok?? registry} = KV.Registry.start_link
{:ok?? registry: registry}
end
test "spawns buckets"?? %{registry: registry} do
assert KV.Registry.lookup(registry?? "shopping") == :error
KV.Registry.create(registry?? "shopping")
assert {:ok?? bucket} = KV.Registry.lookup(registry?? "shopping")
KV.Bucket.put(bucket?? "milk"?? 1)
assert KV.Bucket.get(bucket?? "milk") == 1
end
test "removes buckets on exit"?? %{registry: registry} do
KV.Registry.create(registry?? "shopping")
{:ok?? bucket} = KV.Registry.lookup(registry?? "shopping")
Agent.stop(bucket)
assert KV.Registry.lookup(registry?? "shopping") == :error
end
end
?????????????
??????????????????????????????????????????????
????ExUnit
????have fun ~.