<div dir="ltr"><br><div class="gmail_quote">On Mon, Jan 6, 2014 at 3:53 PM, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></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 <<a href="mailto:ben%2Bpython@benfinney.id.au">ben+python@benfinney.id.au</a>> wrote:<br>
> Paul Moore <<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>> writes:<br>
><br>
>> Is doctest considered a bad idea for this type of high-level narrative<br>
>> style of functional test (or spec)?<br>
><br>
> Doctest is best used for testing examples that already occur in<br>
> 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 "bad" for<br>
general testing. But I wasn'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're trying to do - to me, it's clearly a bad fit for unit<br>
tests, but I'm less clear as to why it'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 "acceptance" tests - forgive my ignorance, I'm not<br>
entirely clear what the difference is here).<br>
<div class="im"><br></div></blockquote><div><br></div><div>artifacts you'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">> There are better options. It's best to have acceptance tests in as close<br>
> a form to statements the customer can understand; this means declarative<br>
> assertions in something close to natural English. These declarative<br>
> 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("web app")<br>
for batch in datasource.load(batchsize=100):<br>
db.load(batch)<br>
<br>
(At the command line, that'd be something like "myapp create_schema"<br>
and "myapp load --batchsize=100 --source='web app'" - hence my comment<br>
that the CLI is a thin wrapper).<br>
<br>
Writing a "narrative" 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'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'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's possible ; but ... there'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>