My book is structured like a tutorial, so each code example in the book
builds on the last --  they don't stand alone.  the book also contains lots
of listings showing commands to run and expected output.

So my test suite works by reading the book as HTML (I prefer that, helps
catch any mistakes in my asciidoc syntax (ascidoc ~=rst)), parsing out all
code examples and command-line listings, and then pretending to be the
user, writing all the code examples to a folder in /tmp, and running all
the commands, checking the outputs are actually as expected.

it's quite challenging, especially as many of the code examples are partial
extracts from a file -- "just change these three lines".  that's easy for
humans to figure out, harder for a computer test suite.  In the end, I
decided to have a parallel series of commits in the test repo for some of
the book's more complicated code examples, one commit per code example in
the book, and then the test script can just check that all the lines in the
commit are in the book, and vice versa, and then use `patch` to apply it...

It is quite possible that I'm over-egging the pudding. test suite is
running at 6,000 lines of code currently. but, it's a book about testing,
so it felt appropriate that it should have good tests.  and, naturally,
there are tests for the tests (for the tests in the book about testing).

cheers!
Harry
http://www.obeythetestinggoat.com



On 24 February 2014 04:49, Aahz <[email protected]> wrote:

> On Sun, Feb 23, 2014, Varied Thoughts wrote:
> >
> > I'm just about to put my first draft into some structure.
> > It's in markdown-ish.
> > I'd like to know more about the test scripts used.
> >
> > What are people using?
>
> My preference is to write in reST and use a custom directive that
> includes both text and output.
> --
> Aahz ([email protected])           <*>
> http://www.pythoncraft.com/
>
> "usenet imitates usenet"  --Darkhawk
> _______________________________________________
> Python-authors mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-authors
>



-- 
------------------------------
Harry J.W. Percival
------------------------------
Twitter: @hjwp
Mobile:  +44 (0) 78877 02511
Skype:         harry.percival
_______________________________________________
Python-authors mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-authors

Reply via email to