<div dir="ltr">On Thu, Jul 24, 2014 at 7:04 AM, C. Titus Brown <span dir="ltr">&lt;<a href="mailto:ctb@msu.edu" target="_blank">ctb@msu.edu</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hey Terry,<br>
Do you have suggestions for a good, concise discussion of<br>
the difference between unit tests and functional tests?<br>
<br>
thanks,<br>
<div class=""><div class="h5">--titus<br>
<br></div></div></blockquote><div><br></div><div>Thought I will give my first 0.01 cent as a recent grad, though most people here have more experience than I do.<br><br>When I was an undergrad I asked here on TIP mailing list: <a href="http://comments.gmane.org/gmane.comp.python.testing.general/5333">http://comments.gmane.org/gmane.comp.python.testing.general/5333</a><br>
<br>In the end, when I gave my talk at school, I refer to <a href="http://googletesting.blogspot.com/2010/12/test-sizes.html">http://googletesting.blogspot.com/2010/12/test-sizes.html</a><br></div><div><br></div><div>There are many types of testing techniques and I&#39;d say screw most of the subtle differences. I went with that table and always remember there are only three types of tests: unit test, integration and functional.<br>
<br></div><div>unit test: true unit test means mocking out all dependencies while testing a specific function or method. This includes built-in functions if necessary (e.g. Math.random) The fewer module interaction the better.<br>
</div><div><br>integration test: mock out necessary module interaction and external systems (filesystem, network, database) whenever possible or whenever I feel it is necessary. When it comes to database model testing, I test individual model and their methods. I can test them with or without a database, depending on how I feel about having a database or not (some ORM makes testing easier!!). I can test the individual model instance creation, update and deletion of models with sqlite or with a real production database like postgresql. The rationel is that (1) I might have PostgreSQL datatype (like JSON) which is not supported by sqlite, or (2) I am going to use postgres in functional test anyway. The time of setting up a fresh database in postgres is not that bad in reality. I can waste 5 seconds for the total 100 model tests if I have to.<br>
<br></div><div>function test: as the google char suggested, go full.<br></div><div><br></div><div>The rest: smoke, regression, etc I just write them as needed. I can careless about their actual definition. When I see a bug, I fix the code, write the assertion and done. Different organization has different opinion on how they write test.<br>
<br></div><div>John<br></div><div><br></div></div></div></div>