[erlang-questions] I Hate Unit Testing...

Steve Davis steven.charles.davis@REDACTED
Wed Jan 28 12:58:38 CET 2009


Thanks, both - interesting stuff.

However, since I'm too lazy to write test code, I'm definitely too lazy 
to read much about writing test code and even less likely to bother to 
learn a whole framework. I have my hands/head full learning the 
Erlang/OTP libraries as it is.

All I want to say is, e.g. hex(4) = "4"  ...and be done with it forever 
(unless I break my code such that hex(4) is no longer "4"). I just can't 
be doing with "assert", "assert_ne" and all that BlahUnit stuff bloating 
out my code (and head).

As a result, you've convinced me that my simple experiment is actually 
MUCH TOO COMPLICATED!! It's inspired me to try another version of 
"utest" that does stuff more like the following:

1) For the test suite, drop the idea of a test spec file and just pull 
that data from the existing .app file (since I already had to write 
that). I can then figure out what modules to test and what dependencies 
to run as well as grab all the info stuff. So for the user...
--->>> Linecount: 0, Filecount: 0.

2) Have utest look for the module test cases as mymodule.test files 
which I'll probably dump into an app subfolder called...um... "test".
-->>> Linecount: 1 per test, Filecount: 1 TEXT file per module

3) Make the syntax of the test (text) files as close to erlang 
semantically as possible without being too sensitive to syntax... that 
way I barely have to change brain-gear from coding to testing and so I 
may even bother to add test cases (i.e. lines) to the test file as i go 
along...

----- my_module.test ----
hex(4) = "4"
hex(5) /= "6"
hex(3) =:= "3"
dehex($3) > 20

..etc...

Since I'm using erlang operators I might just as well allow boolean 
operators too... and, or, orelse, andalso... and then we can start 
getting fancy with our test cases...

start(80) = {ok, _} and get_port() =:= 80 and 
myapp_control:get_started() = 1

I guess I could make utest a parameterized module to set the config up, 
so all in all a console session could then end up looking something like 
this...

1>Test = utest:new(myapp, terse).
2>Test:run().
[FAIL] my_module:hex(4) -> 52 EXPECTED "4"
{fail, [{tests, 294}, (errors, 1}]}
3>c(my_module).
{ok, my_module}
4>Test:run().
{ok, [{tests, 294}, (errors, 0}]}
5>

What do you think? :)

/s




More information about the erlang-questions mailing list