[racket] Rackunit best practices

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Aug 22 02:35:49 EDT 2013

People go back and forth on tests/A and A/tests, but I think the current
thought is that A/tests is better than tests/A (altho with the package
manager, the original rationale for that (keeping the code and the tests
more together) seems to be gone.

But yeah, I'd definitely agree that a top-level tests submodule is a clear
indication of tests.

Robby


On Thu, Aug 22, 2013 at 1:27 AM, Laurent <laurent.orseau at gmail.com> wrote:

> Quickly: It is common to use a  submodule for tests, in the same source
> file:
> (module+ test
>   (require rackunit)
>   ....)
>
> then running `raco test <file.rkt> ...` will run all the tests. Such tests
> are also automatically run in DrRacket when you press run (along with the
> 'main' submodule).
>
> For packages that have a collection A, it is also common (and considered
> good practice) to have another collection 'test' with a subdirectory for A
> and its tests.
> See for example the xml-rpc repo: https://github.com/jeapostrophe/xml-rpc
> This is partly intended for use with DrDr (that runs `raco test`), a tool
> written by Jay for the development of Racket. I don't know much more about
> it, but other people on this list do.
>
>  Laurent
>
>
> On Thu, Aug 22, 2013 at 7:54 AM, Chad Albers <calbers at neomantic.com>wrote:
>
>> As a Ruby engineer, we have a wonderful tool called "guard" that
>> automatically runs our unit-tests every time a test-case changes or
>> every-time a source file changes.
>>
>> I have written a guard plugin that performs the same task for Racket's
>> rackunit.  Currently, it pretty primitive - guard runs all tests if
>> anything changes - and it makes several assumptions about how tests
>> are structured.
>>
>> guard's ruby unit test plug works so well because there is a set of
>> informal conventions that Ruby developers follow, and guard's ruby
>> plugin works so well because it can counts on those conventions.
>>
>> Before I release "guard-rackunit" to the general public, I am
>> wondering if similar conventions exist for rackunit.
>>
>> For instance, in my Racket project, the following conditions hold true
>> 1. all tests are located at the root of the project in a directory call
>> "tests"
>> 2. in the "tests" directory, I have a "test-runner.rkt" file that
>> performs all '(run-tests *).
>> 3. Each test-suite file contains one 'provide' which corresponds to
>> the name of the test-suite
>> 4. Each test-suite file is name after the file that it tests and
>> appends "-test.rkt"; eg. foo.rkt corresponds to foo-test.rkt
>>
>> If the Racket community follows a different set of conventions, I can
>> change my guard plugin to follow those conventions, and only have
>> guard run a test suite for the file it tests.
>>
>> Let me know 1) if there is any interest in this project, and 2) a set
>> of conventions that I can generally depend upon.
>>
>> Thanks,
>> Chad
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130822/19c3ec34/attachment.html>

Posted on the users mailing list.