<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Virtual Clouds &#187; testing</title>
	<atom:link href="http://www.virtual-clouds.com/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.virtual-clouds.com</link>
	<description>Erlang and Other Animals</description>
	<lastBuildDate>Mon, 19 Jul 2010 17:42:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>code coverage in erlang</title>
		<link>http://www.virtual-clouds.com/2008/10/24/code-coverage-in-erlang/</link>
		<comments>http://www.virtual-clouds.com/2008/10/24/code-coverage-in-erlang/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 22:15:17 +0000</pubDate>
		<dc:creator>ofer affias</dc:creator>
				<category><![CDATA[methodology]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.virtual-clouds.com/?p=24</guid>
		<description><![CDATA[yesterday i found about code coverage under erlang on this nice blog. i wanted to integrate it with my unit testing, so i would be able to see what code of mine is not tested. this can be used to add new tests to cover it, or even remove of unnecessary code. it took me <a href='http://www.virtual-clouds.com/2008/10/24/code-coverage-in-erlang/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>yesterday i found about code coverage under erlang on this nice <a href="http://curious-attempt-bunny.blogspot.com/2007/10/code-coverage-analysis-in-erlang.html">blog</a>. i wanted to integrate it with my unit testing, so i would be able to see what code of mine is not tested. this can be used to add new tests to cover it, or even remove of unnecessary code.</p>
<p>it took me some time to play with it and come up with a good method of doing that. eventually i have replaced the unit testing makefile line with:</p>

<div class="wp_syntax"><div class="code"><pre class="make" style="font-family:monospace;">check<span style="color: #004400;">:</span>
	<span style="color: #004400;">@</span>for f in <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MODULES</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">;</span> do \
	echo <span style="color: #000088; font-weight: bold;">$$</span>f<span style="color: #004400;">;</span> \
	erl <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">FLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>noshell <span style="color: #004400;">-</span>eval <span style="color: #CC2200;">&quot;
	cover:compile($$f, [{i,<span style="color: #000099; font-weight: bold;">\&quot;</span>$(INCLUDE)<span style="color: #000099; font-weight: bold;">\&quot;</span>}]),<span style="color: #000099; font-weight: bold;">\</span>
	$$f:test(),
	cover:analyse_to_file($$f, <span style="color: #000099; font-weight: bold;">\&quot;</span>$(DOC)/$${f}_coverage.html<span style="color: #000099; font-weight: bold;">\&quot;</span>, [html]).&quot;</span>\
	<span style="color: #004400;">-</span>s init stop<span style="color: #004400;">;</span> \</pre></div></div>

<p>This actually do 3 things in a raw:</p>
<ol>
<li>compile each module using cover:compile.</li>
<li>run the test, using the eunit test() function.</li>
<li>dump analysis into html files on doc directory</li>
</ol>
<p>enjoy!</p>
<p>edit: i found out, that you compile the whole directory for covearge, so the result you get is thecombined  coverage for all the specified modules and tests.</p>

<div class="wp_syntax"><div class="code"><pre class="make" style="font-family:monospace;">OBJECTS <span style="color: #004400;">:=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">patsubst</span> <span style="color: #004400;">%.</span>erl<span style="color: #004400;">,$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">BIN</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">/%.$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">EMULATOR</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">,$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>erl<span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span>
MODULES <span style="color: #004400;">:=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">patsubst</span> <span style="color: #004400;">%.</span>erl<span style="color: #004400;">,%,$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>erl<span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span>
SKIP_FILES <span style="color: #004400;">:=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">patsubst</span> <span style="color: #004400;">%.</span>erl<span style="color: #004400;">,%,$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*</span>_tests<span style="color: #004400;">.</span>erl<span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span>
MODULES <span style="color: #004400;">:=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">filter-out</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">SKIP_FILES</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">,</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MODULES</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span>
MODULES <span style="color: #004400;">:=</span> <span style="color: #004400;">&#91;</span><span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">subst</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">space</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">,$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">comma</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">,$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MODULES</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">&#93;</span>
&nbsp;
check<span style="color: #004400;">:</span>
	<span style="color: #004400;">@</span>echo Testing units<span style="color: #004400;">...</span>
	<span style="color: #004400;">@$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">TIME</span><span style="color: #004400;">&#41;</span> erl <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">ERL_LIB_FLAGS</span><span style="color: #004400;">&#41;</span> \
	<span style="color: #004400;">-</span>mnesia dir <span style="color: #CC2200;">'&quot;$(DATA_DIR)&quot;'</span> <span style="color: #004400;">-</span>mnesia debug <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MNESIA</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>noshell \
	<span style="color: #004400;">-</span>eval <span style="color: #CC2200;">&quot;<span style="color: #000099; font-weight: bold;">\</span>
	cover:compile_directory(<span style="color: #000099; font-weight: bold;">\&quot;</span>.<span style="color: #000099; font-weight: bold;">\&quot;</span>, [{i,<span style="color: #000099; font-weight: bold;">\&quot;</span>$(INCLUDE)<span style="color: #000099; font-weight: bold;">\&quot;</span>},{d,'NODEBUG'}]), <span style="color: #000099; font-weight: bold;">\</span>
	T = fun(X) -&gt; io:format(user, <span style="color: #000099; font-weight: bold;">\&quot;</span>~-20.s<span style="color: #000099; font-weight: bold;">\&quot;</span>, [X]), X:test() end, <span style="color: #000099; font-weight: bold;">\</span>
	[T(X) || X &amp;lt;- &quot;</span><span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MODULES</span><span style="color: #004400;">&#41;</span><span style="color: #CC2200;">&quot;], <span style="color: #000099; font-weight: bold;">\</span>
	F = fun(X) -&gt; cover:analyse_to_file(X, <span style="color: #000099; font-weight: bold;">\&quot;</span>$(LOG)/<span style="color: #000099; font-weight: bold;">\&quot;</span> ++ <span style="color: #000099; font-weight: bold;">\</span>
	    atom_to_list(X) ++ <span style="color: #000099; font-weight: bold;">\&quot;</span>_coverage.html<span style="color: #000099; font-weight: bold;">\&quot;</span>, [html]) end, <span style="color: #000099; font-weight: bold;">\</span>
	[F(X) || X &amp;lt;- &quot;</span><span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MODULES</span><span style="color: #004400;">&#41;</span><span style="color: #CC2200;">&quot;]. <span style="color: #000099; font-weight: bold;">\</span>
	&quot;</span> <span style="color: #004400;">-</span>s init stop<span style="color: #004400;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.virtual-clouds.com/2008/10/24/code-coverage-in-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>more on eunit</title>
		<link>http://www.virtual-clouds.com/2008/10/6/more-on-eunit/</link>
		<comments>http://www.virtual-clouds.com/2008/10/6/more-on-eunit/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 21:32:10 +0000</pubDate>
		<dc:creator>ofer affias</dc:creator>
				<category><![CDATA[methodology]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.virtual-clouds.com/?p=6</guid>
		<description><![CDATA[the use of eunit is very easy and intuitive. in principle every function which ends with _test of arity 0 (i.e. no input arguments) will be automaticly exported by eunit. eunit will also create a function called test() which will call all tests functions which have been defined. this mechanism leaves the programmer with only <a href='http://www.virtual-clouds.com/2008/10/6/more-on-eunit/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>the use of eunit is very easy and intuitive. in principle every function which ends with _test of arity 0 (i.e. no input arguments) will be automaticly exported by eunit. eunit will also create a function called test() which will call all tests functions which have been defined. this mechanism leaves the programmer with only the actual test writing, and saves him/her the tedious wrappers and procedures. writing a test on a new module become something which take few seconds.</p>
<p>for example, the next function has its own testing function:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">flip_sides</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Side</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #186895;">case</span> <span style="color: #45b3e6;">Side</span> <span style="color: #186895;">of</span>
		x <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">o</span><span style="color: #6bb810;">;</span>
		o <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">x</span>
	<span style="color: #186895;">end</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">flip_sides_test</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	?<span style="color: #ff3c00;">assert</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">flip_sides</span><span style="color: #109ab8;">&#40;</span>x<span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">==</span> o<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
	?<span style="color: #ff3c00;">assert</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">flip_sides</span><span style="color: #109ab8;">&#40;</span>o<span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">==</span> x<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>the testing function is invoked automatically by calling the test function of this module, e.g. mymodule:test(). the test function is supplied by the eunit framework, which takes every function that ends with _test() and add it to the testing list of that module.</p>
<p>a more advanced testing method is needed for testing the always loops that keep the state on the erlang module. few problems need to be solved in order to properly test those kind of loops:</p>
<ul>
<li> initial state loading.</li>
<li> external function calls.</li>
<li> check of the new state, after each event.</li>
<p></lu></p>
<p>the first problem can be solved by adding a new start function for debug use, which takes all the state variables of the always loop as parameters. this allows you to start the always loop in any state you want.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">% original start of arity/0</span>
<span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">% new function for debug of arity/2</span>
<span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>  <span style="color: #ff3c00;">register</span><span style="color: #109ab8;">&#40;</span>?<span style="color: #6941fd;">MODULE</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">spawn</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">% the state loop</span>
<span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #186895;">receive</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> stop<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">From</span> <span style="color: #014ea4;">!</span> stopped<span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> reset<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>add<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span>module2:<span style="color: #ff3c00;">add</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">N</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> continue<span style="color: #109ab8;">&#41;</span>
	<span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>the next problem is the call for external function, shown here as call for module2:add/2, i solved this by adding another parameter to the loop&#8217;s state in order to keep a reference to the called function. i have also added it to the start function.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">% original start of arity/0</span>
<span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #6bb810;">,</span> <span style="color: #186895;">fun</span> module2:<span style="color: #006600;">add</span><span style="color: #014ea4;">/</span><span style="color: #ff9600;">2</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">% new function for debug of arity/2</span>
<span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #ff3c00;">register</span><span style="color: #109ab8;">&#40;</span>?<span style="color: #6941fd;">MODULE</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">spawn</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">% the state loop</span>
<span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #186895;">receive</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> stop<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">From</span> <span style="color: #014ea4;">!</span> stopped<span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> reset<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>add<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">F</span><span style="color: #ff3c00;">unc</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">N</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> continue<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span>
	<span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>adding a reference to the external function allows me to switch to a mocking function as desired. for the new state checking i have added a dump command to the always loop which return me the current state, so i can test it on my testing functions.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">% the state loop</span>
<span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Status</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #186895;">receive</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> stop<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">From</span> <span style="color: #014ea4;">!</span> stopped<span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> reset<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">From</span> <span style="color: #014ea4;">!</span> reset<span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>add<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">always</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">F</span><span style="color: #ff3c00;">unc</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">N</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> continue<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
		<span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">From</span><span style="color: #6bb810;">,</span> dump<span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">State</span><span style="color: #6bb810;">,</span> dump<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Func</span><span style="color: #109ab8;">&#125;</span>
	<span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>last i&#8217;ll show the test function:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">always_reset_test</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #45b3e6;">Fun</span> <span style="color: #014ea4;">=</span> <span style="color: #186895;">fun</span> callback_check_reset_mockup<span style="color: #014ea4;">/</span><span style="color: #ff9600;">2</span><span style="color: #6bb810;">,</span>
	<span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>x<span style="color: #6bb810;">,</span> o<span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> continue<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Fun</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
	<span style="color: #ff3c00;">rpc</span><span style="color: #109ab8;">&#40;</span>reset<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
	?<span style="color: #ff3c00;">assert</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">rpc</span><span style="color: #109ab8;">&#40;</span>dump<span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">==</span> <span style="color: #109ab8;">&#123;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> start<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Fun</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
	<span style="color: #ff3c00;">stop</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>callback_check_reset_mockup(N, State) ->  void. % you can check match if applicable
</pre>
<p>that's it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.virtual-clouds.com/2008/10/6/more-on-eunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
