Confirmed users
161
edits
(link to Necko:UnitTests) |
|||
Line 4: | Line 4: | ||
== Creating the first test for a module == | == Creating the first test for a module == | ||
This section explains what needs to be done before creating a unit test for a module that doesn't have any tests yet: | This section explains what needs to be done before creating a unit test for a module that doesn't have any tests yet: | ||
<ol> | |||
<li>Copy <tt>mozilla/tools/test-harness/xpcshell-simple/example</tt> to <tt>''yourmoduledir''/test</tt></li> | |||
<li>In <tt>''yourmoduledir''/test/Makefile.in</tt> change <code>DEPTH</code> and <code>MODULE</code> appropriately:</li> | |||
<ul> | |||
<li><code>DEPTH</code> should be a relative path pointing to <tt>mozilla/</tt>, e.g. if you're in <tt>netwerk/test</tt>, set <code>DEPTH = ../..</code></li> | |||
<li><code>MODULE</code> should have a value of form <code>test_''yourmodule''</code>.</li> | |||
</ul> | |||
<li>Reference the test dir in a parent makefile (<tt>''yourmoduledir''/Makefile.in</tt>): | |||
<pre>ifdef ENABLE_TESTS | |||
TOOL_DIRS += test | |||
endif</pre></li> | |||
<li>(Optional, but recommended) Add the new makefile to [[allmakefiles.sh]] (TODO: need more details about this)</li> | |||
<li>Reconfigure (e.g. with <tt>make -f client.mk configure</tt>)</li> | |||
<li>''make'' / ''make check'' in <tt>''yourmodule''</tt></li> | |||
</ol> | |||
You're now ready to start writing unit tests themselves. | You're now ready to start writing unit tests themselves. |