unit test - makefile에서... make file에 다음과 같은 부분을 추가한 후에, make test 하면 간편하게 명령행에서 unit test를 수행할 수있다. (makefile 뼈대는 Programming Erlang을 기초로 했다.)
...... MODS = doc str_util db i18n tiny_scan ......
test: compile test_subdirs rm -rf Mnesia.nonode@nohost # removes previous mneisa db (optional). @for m in ${MODS};\ do \ echo "testing $$m";\ ${ERL} -noshell -pz "subdir1" -pz "subdir2" -s $$m test -s init stop;\ done
test_subdirs: cd subdir1; make test cd subdir2; make test
unit test, coverage test - 개발중 REPL(distel 또는 erl prompt) 에서... REPL을 사용해서 (멋지게) 코딩-테스트를 반복중이라면, 다음과 같은 모듈을 하나 디렉토리에 넣어서 test:unit() 또는 test:cover() 를 실행시켜서 unit test 및 coverage test를 시시때때로 수행해 볼 수 있다.
%%%------------------------------------------------------------------- %%% File : test.erl %%% Author : manywaypark <manywaypark@gmail.com> %%% Description : some test codes. %%% %%% Created : 11 Aug 2008 by manywaypark <manywaypark@gmail.com> %%%------------------------------------------------------------------- -module(test).