Re: How to use CPPUnit effectively?
jolz wrote:
>Easy - run many of them.
>
And if 1000 passes succedes that means that everything is ok? I don't
tink so.
I tink that would be a bad test.
example of bad test removed. I can write bad tests too...
Many people beg to differ. Sure, you can write a bogus test, bets are
however that if you don't do it you're likely going to find a problem as
a customer report which is far more costly.
My experience is the opposite.
Exactly, so run it on a bunch of different test machines. I reccomend a
dual platform development for exactly this reason. Linux-posix + Win32
is a great combination.
again - bad test. You have to run a dual CPU or better to run
multithreaded tests. Also your test has too much overhead, you create
new threads all the time. I usually create a parameterized number of
threads make them all arrive at a barrier and then unleash them all at
the same time. Then I run the test with those threads throughout the
entire test.
Again, your clever, write a better test.
This argument sounds like: "Doctor doctor, it hurts when I point a gun
at my foot and shoot". Well, duh !
You can't test every situation all the time, nobody argues that. The
question is, what is the cost/benefit of doing some. Clearly if you
have no tests you're running blind. If you have some tests you're
better off and so on until there is a diminishing return. Maybe you can
use this principle. "If I write a unit test and it finds no bugs, then I
stop and move onto the next project."
Use common sense at first and be a little conservative. It depends on
the app.
There are frameworks for testing GUI. I'm not familiar with the state
of the art. I was hinting at being careful about being distinct from
function and appearance. I agree that you can't test if something is
aesthetic, but you can test if somthing works.
I think you're wrong here. I have yet to meet a programmer that can
write code without bugs.
jolz wrote:
>>How do I test concurrency?
And if 1000 passes succedes that means that everything is ok? I don't
tink so.
... For example:
...really mean anything.
however that if you don't do it you're likely going to find a problem as
a customer report which is far more costly.
... Real life examples are much more
subtle.
subtle.
... Also the same test may work on one comuter + compiler +
operating system (for example test machine) and fail on every other.
operating system (for example test machine) and fail on every other.
dual platform development for exactly this reason. Linux-posix + Win32
is a great combination.
It runs about a minute on my computer. If I would have to test this way
all functions in 500000 line application it would take a lot of time.
all functions in 500000 line application it would take a lot of time.
multithreaded tests. Also your test has too much overhead, you create
new threads all the time. I usually create a parameterized number of
threads make them all arrive at a barrier and then unleash them all at
the same time. Then I run the test with those threads throughout the
entire test.
And usually 1 fuction have more than 1 test.
Notice that single look at the code proves that code is wrong, but
100000 passes of the test gave the illusion that everything is ok.
Notice that single look at the code proves that code is wrong, but
100000 passes of the test gave the illusion that everything is ok.
This argument sounds like: "Doctor doctor, it hurts when I point a gun
at my foot and shoot". Well, duh !
>
>Have you app code read/write to an abstracted layer that you can
>simulate those kinds of failures.
>
But this way I have to change my code. Well, it may lead to a better
design, but still the test tests the abstract layer and not the actual
problem.
>>How do I test proper excepion handling after disk failure?
>simulate those kinds of failures.
But this way I have to change my code. Well, it may lead to a better
design, but still the test tests the abstract layer and not the actual
problem.
question is, what is the cost/benefit of doing some. Clearly if you
have no tests you're running blind. If you have some tests you're
better off and so on until there is a diminishing return. Maybe you can
use this principle. "If I write a unit test and it finds no bugs, then I
stop and move onto the next project."
>
>Run the test on large data sets and limit the execution time.
>
Remember - first write test, than write code. So how do you guess what
is the correct time? And what happens if test is run on a faster
machine? I guess it will pass every time even is something was broken.
>>How do I test efficiency of used algorithm?
Remember - first write test, than write code. So how do you guess what
is the correct time? And what happens if test is run on a faster
machine? I guess it will pass every time even is something was broken.
the app.
>
Those were only examples. In real life there are much more of those (so
far I think that we agree that gui is not unit testable, and there are
lots of developers that do only gui).
Those were only examples. In real life there are much more of those (so
far I think that we agree that gui is not unit testable, and there are
lots of developers that do only gui).
of the art. I was hinting at being careful about being distinct from
function and appearance. I agree that you can't test if something is
aesthetic, but you can test if somthing works.
>
>So ? The tests can take some time to write but it is far less expensive
>and much more useful to find the bugs before it gets to the customer.
>
But even less expensive is simply looking into the code and thinking
what to do to make it right, not what to do to make some test pass.
Test will pass anyway.
>>Also probanly everybody who write tests spent a lot of time debuging
>>working code and finding that the mistake was in the test.
>>working code and finding that the mistake was in the test.
>and much more useful to find the bugs before it gets to the customer.
But even less expensive is simply looking into the code and thinking
what to do to make it right, not what to do to make some test pass.
Test will pass anyway.
write code without bugs.
Comment