¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: [TDD] How do you write tests if you aren't sure what the result should be?


 

Yes, the code is the same.

See
from

for another example, where how accurate your timer or framerate is can
affect the results of the tests.

In the gravity example, if I run the equation as if the user has 10 frames
per second, I will get different results than if they run at 60 frames per
second.
Granted this is partially a problem with the code, but it should still be
testable.

Perhaps this is the Heisenberg of unit testing?



brought to you by the letters A, V, and I
and the number 47


On Fri, Feb 15, 2013 at 10:40 PM, George Dinwiddie
<lists@...>wrote:

**


Avi,


On 2/15/13 4:24 AM, Avi Kessner wrote:
Thank you for your help and suggestions so far.
My actual use case is a bit boring, but I found a more fun analogy.
Say you were asked to make a change to a game called Yetti Sport.

The object of the game is that you hit a penguin and it flies across the
screen until it stops bouncing or getting blown up by mines.
The task required is that you place a marker or some graphic on the spot
where the penguin will land at the end of the run. However, the marker
needs to be placed before the spot becomes visible.

This means that you need to use the current state of the game to predict
where the penguin will land, and place a graphic exactly there before all
the animations for the penguin flying through the air are done.
Is the calculation of the penguin's movement and the calculation of the
marker position both done by the unit under test?

- George



If I was doing this without unit tests, I would run the game wait for it
to
keep bouncing for x number of seconds, and see if the marker showed up in
the right place or not. Not a very efficient test.

Ideally however, I don't just want to have acceptance tests that it
works,
I also want my tests to help me develop the solution. (aka TDD)
It seems to me that this should be possible (cause it's just math being
done over some variable data etc) but I can't figure out what I'm missing
to make it work. My problem with putting in values such as 0 or 1 is that
while I should get 0 distance with an input of 0, that doesn't actually
help me solve the problem. What do I do for inputs greater than zero?

brought to you by the letters A, V, and I
and the number 47


On Fri, Feb 15, 2013 at 1:23 AM, Wouter Lagerweij wouter@...
wrote:

**


Hi Avi,

I'm not sure whether this is applicable to your situation, but I also
had a
case where we were calculating some complex formulas and I couldn't get
an
exact result predicted, simply because the system was meant to be able
to
calculate those results with more precision than was possible before.

In that situation, we were able to define our (acceptance) tests to
accept
approximate values, within a given range. So the expected outcome would
for
instance be 0.546 +/- 0.5%
We also had to control some of the inputs to the system, such as the
seed
used to generate random values that were used in the calculations, which
would normally change with time.

Is that something that might work in your circumstances?

Wouter

On Thu, Feb 14, 2013 at 5:31 PM, Charlie Poole charliepoole@...
wrote:

Hi Avi,

If you had to test your work only by direct observation, what would you
look for?

Charlie


On Thu, Feb 14, 2013 at 7:21 AM, Avi Kessner akessner@...>
wrote:

**


Ill write more later when I'm at my desk, but the use case here is
matching
and predicting animations

On Feb 14, 2013 5:15 PM, "Steven Gordon" sgordonphd@...> wrote:

Even when the math is complicated, there should be inputs where the
results
are easy to hand compute. For example, where the inputs are
combinations
of 0s, 1s, -1s, etc. Those trivial cases should be enough to drive
development of properly structured code.

I would depend on customer-level tests to see if the computations are
properly supporting whatever "business" functionality the system is
supposed to deliver. If wrong answers still allows the user to do
what
they need to do, then maybe the fancy formulas are overkill anyway.

SteveG

On Thu, Feb 14, 2013 at 12:24 AM, Avi Kessner akessner@...>
wrote:

**


Hi, I have a simple question.
I've been developing my program with TDD however I have hit a snag
and
I'm
not sure how to continue.
We have some complicated mathematical formulas that interact with
each
other The math is too complicated for me to resolve easily. These
formulas are calculated based on time. (For example, an elastic
tween
formula)
I need to write a series of functions which predict what the steps
of
the
formula will be. (How many timer ticks will it take to get to point
A?)

This is something that I feel can have tests, and needs tests. But
I
have
no idea what to check or how to know if the test is correct.

My actual question is a meta-question by the way. How do I write
tests
when I don't know what the results should be, but I know the
computer
needs
to get the "correct" result?

Thanks.

brought to you by the letters A, V, and I
and the number 47





[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links







[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links



--
Wouter Lagerweij | wouter@...
| @wouterla !/wouterla>


[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links



--
----------------------------------------------------------
* George Dinwiddie *
Software Development
Consultant and Coach
----------------------------------------------------------



[Non-text portions of this message have been removed]

Join [email protected] to automatically receive all group messages.