Talk:SoftwareTesting:Tools:Simple xpcshell test harness: Difference between revisions

(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:
# Copy <tt>mozilla/tools/test-harness/xpcshell-simple/example</tt> to <tt>''yourmoduledir''/test</tt>
<ol>
# In <tt>''yourmoduledir''/test/Makefile.in</tt> change <code>DEPTH</code> and <code>MODULE</code> appropriately:
<li>Copy <tt>mozilla/tools/test-harness/xpcshell-simple/example</tt> to <tt>''yourmoduledir''/test</tt></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>In <tt>''yourmoduledir''/test/Makefile.in</tt> change <code>DEPTH</code> and <code>MODULE</code> appropriately:</li>
#* <code>MODULE</code> should have a value of form <code>test_''yourmodule''</code>.
<ul>
# Reference the test dir in a parent makefile (<tt>''yourmoduledir''/Makefile.in</tt>)
<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>
# (Optional, but recommended) Add the new makefile to [[allmakefiles.sh]] (TODO: need more details about this)
<li><code>MODULE</code> should have a value of form <code>test_''yourmodule''</code>.</li>
# Reconfigure (e.g. with <tt>make -f client.mk configure</tt>)
</ul>
# ''make'' / ''make check'' in <tt>''yourmodule''</tt>
<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.
Confirmed users
161

edits