[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SRFI 64: How do I create a test-runner stub

From: sirgazil
Subject: Re: SRFI 64: How do I create a test-runner stub
Date: Fri, 8 Mar 2019 08:24:41 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Hi, Christopher,

Thanks for the links, but I'm no actually looking for a custom rest-runner. I'm writing my own as an exercise, and it looks similar to your `gnc:test-runner`. My runner already prints to standard output and logs results in a manner I like better than Guile's default test-runner.

The thing is, I'm writing tests to test the functions that compose my test-runner. One of this functions is `format-test-result` which receives a test-runner object as an argument. That's why I need to know how to create a fake test-runner that has the same interface of a real test-runner object.

Extending a fake runner from `(test-runner-null)`, for example, didn't quite work for me because I couldn't find a way to set a `test-name` slot in the object, so that the `test-runner-test-name` getter can be called on fake runners and return whatever name I set in them.

El 7/03/19 a las 6:40 p. m., Christopher Lam escribió:

In gnucash I've resorted to writing my own srfi-64 test-runner. See the entry point at (run-test-proper) at

Its definition is at <> and takes care of both returning #f if any test fails, and also doing an IMHO better job at logging tests.

On Thu, 7 Mar 2019 at 21:03, sirgazil <address@hidden <mailto:address@hidden>> wrote:


    I'm trying to implement a procedure that takes a test-runner object and
    returns a string with information about the most recently run test. For
    example, calling

        (format-test-result (make-runner #:test-name "A is not B."
    #:result-kind 'fail))

    is expected to return:

        ✖ FAIL A is not B.

    In the example, `make-runner` is a procedure that is supposed to create
    a test-runner stub with the given values, so that I can test the
    `format-test-result` procedure.

    I thought I could define `make-runner` body like this:

        (let ((runner-stub (test-runner-null)))
          (test-runner-test-name! runner-stub test-name)
          (test-result-set! runner-stub 'result-kind result-kind)

    The problem is, the `test-runner-test-name!` setter does not exist. And
    test-runner objects don't seem to have a `test-name` slot. They do
    provide a `test-runner-test-name` getter, though.

    So I don't know how to create a test-runner stub to test my procedure.

    What would you do in this case?

-- Luis Felipe López Acevedo

Luis Felipe López Acevedo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]