lua-users home
lua-l archive

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

Sean Conner <> wrote:
> I did not feel my question was disingenious or silly, as I *really* did
> not know why* anyone even bothers with testing frameworks.  While Alexey
> provided *an* answer (well, four really), they didn't explain to me *why* a
> framework is needed, as the four items he mentioned could be done without a
> framework.

(I don’t know you, so I don’t know if you’re playing with semantics. I’ll
play along once and assume you’re being serious.)

Anything can be done without a framework, though sometimes (often?) you’ll
need to write a minimal version of a framework to do it. Alexy mentioned,
for example, setup/teardown tasks: that is, the ability to perform some
task or group of tasks before each test is run. You don’t have to use
a framework to do this, but you would have to write something similar in
effect to a framework in order to get the same result. The same goes for
what Alexy said about (1) additional assert functions (e.g., more specific
assertions and deep comparison of tables) and (2) error messaging. (Btw,
people keep focusing on colors and “pretty” messages, but clear,
consistent, machine-readable error messaging can be very useful without
being mere fluff. E.g., there are many pre-existing tools that you can plug
TAP output into. That’s a big plus for me. This is not to say that anyone
must use TAP. My point is just that it’s easy to mock “pretty” output, but
consistent ouput can be more than pretty. And once we’re writing computer
programs anyhow, why not offload much of the work of ensuring consistency
to the computer?)

The word ‘framework’ may be the problem. Perhaps you understand it to mean
“huge bundle of (potentially buggy) code, much of which is useless or mere
decoration”. But I suspect many of us use ‘framework’ here no differently
than ‘module’ or ‘library’. If you want to write anything beyond tests with
Lua’s built-in assert, you have to either use a test module or write your
own. This is why I couldn’t believe that you really didn’t understand *why*
people use test frameworks, i.e. test libraries.  They use them for the
same reason that they use *any* libraries. And I can’t take seriously that
you (someone who seems very familiar with programming) don’t know why
people use libraries. You may prefer to use your own code—many people
do—but that’s not the same as saying “I simply don’t understand why people
don’t write their own everything”. That’s the kind of thing I took to be
disingenuous or silly.

> (like the randomized order case---question: does *any* Lua testing
> framework provide *that* functionality?) [1].

I’m not aware of one. I first came across that concept in Ruby’s minitest
library, though I don’t mean to say that it was invented there. minitest is
a framework, but relatively minimal. You might even like it despite yourself.

Best, Peter
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System