<div dir="ltr"><br><div class="gmail_quote">On Mon, Jan 6, 2014 at 3:53 PM, Paul Moore <span dir="ltr">&lt;<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 6 January 2014 20:12, Ben Finney &lt;<a href="mailto:ben%2Bpython@benfinney.id.au">ben+python@benfinney.id.au</a>&gt; wrote:<br>
&gt; Paul Moore &lt;<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>&gt; writes:<br>
&gt;<br>
&gt;&gt; Is doctest considered a bad idea for this type of high-level narrative<br>
&gt;&gt; style of functional test (or spec)?<br>
&gt;<br>
&gt; Doctest is best used for testing examples that already occur in<br>
&gt; documentation, such as API references or tutorials.<br>
<br>
</div>Thanks. I was aware that was the intended use for doctest, and I had<br>
also seen plenty of comments to the effect that doctest is &quot;bad&quot; for<br>
general testing. But I wasn&#39;t able to find much in the way of clear<br>
explanations of *why* it is bad. Obviously it depends on what sort of<br>
tests you&#39;re trying to do - to me, it&#39;s clearly a bad fit for unit<br>
tests, but I&#39;m less clear as to why it&#39;s inappropriate for functional<br>
tests </blockquote><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(you refer to &quot;acceptance&quot; tests - forgive my ignorance, I&#39;m not<br>

entirely clear what the difference is here).<br>
<div class="im"><br></div></blockquote><div><br></div><div>artifacts you&#39;ll deliver to end-users / clients not necessarily aware of testing , programming , ... subtleties [1]_</div><div> </div><div>[...]</div><div><br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">&gt; There are better options. It&#39;s best to have acceptance tests in as close<br>
&gt; a form to statements the customer can understand; this means declarative<br>
&gt; assertions in something close to natural English. These declarative<br>
&gt; assertions can then be parsed and tested by executable test code.<br>
<br>
</div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In the case of my application, the end user is basically myself. I am<br>
writing a command line utility. In actual fact, the CLI is essentially<br>
likely to be a thin wrapper around a library API, and my real focus at<br>
this point is on getting the API correct. Something like<br>
<br>
    db = myapp.DB()<br>
    db.create_schema()<br>
    datasource = Source(&quot;web app&quot;)<br>
    for batch in datasource.load(batchsize=100):<br>
        db.load(batch)<br>
<br>
(At the command line, that&#39;d be something like &quot;myapp create_schema&quot;<br>
and &quot;myapp load --batchsize=100 --source=&#39;web app&#39;&quot; - hence my comment<br>
that the CLI is a thin wrapper).<br>
<br>
Writing a &quot;narrative&quot; like that gives me a good idea of how I want the<br>
API to work, and I was asking my question because that feels so close<br>
to a doctest.<br></blockquote><div><br></div><div>FWIW , I&#39;ve been thinking since some time ago of adding in dutest support for command line tools . Yes , this would be possible to achieve by overriding dutest.DocTestCase methods , the runner , etc ... to achieve that each interactive example is executed by the shell and match it&#39;s ouput just like doctest would .</div>
<div><br></div><div>If this is close to what you are looking for (and I understood correctly) then , yes , it&#39;s possible ; but ... there&#39;s nothing (that I know) actually written to satisfy your requirements . </div>
<div><br></div><div>Again, there are other options out there .</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div>[...]<br clear="all"><br>-- <br>Regards,<br><br>Olemis - @olemislc<br><br>Apache™ Bloodhound contributor<br><a href="http://issues.apache.org/bloodhound">http://issues.apache.org/bloodhound</a><br><a href="http://blood-hound.net">http://blood-hound.net</a><br>
<br>Blog ES: <a href="http://simelo-es.blogspot.com/">http://simelo-es.blogspot.com/</a><br>Blog EN: <a href="http://simelo-en.blogspot.com/">http://simelo-en.blogspot.com/</a><br><br>Featured article:<br><br><br>
</div>