Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
- Testdrivendevelopment
- Messages
Search
Re: [TDD] How do you write tests if you aren't sure what the result should be?
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. 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: ** [Non-text portions of this message have been removed] |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Hi Avi,
toggle quoted message
Show quoted text
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, --
Wouter Lagerweij | wouter@... | @wouterla <!/wouterla> |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
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: ** [Non-text portions of this message have been removed] |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Ill write more later when I'm at my desk, but the use case here is matching
toggle quoted message
Show quoted text
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 |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
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: ** [Non-text portions of this message have been removed] |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Pascal Roy
I don't think the problem is directly related to TDD per say. Let me rephrase your
question to point out what the real problem is : "How do you know your computation is right if you're not even sure what the results should be?" I would say, it's a pretty fundamental issue... Pascal Roy www.elapsetech.com Le 2013-02-14 à 05:57, Angel Java Lopez <ajlopez2000@...> a écrit : Hi people! [Non-text portions of this message have been removed] |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Hi Avi,
On Thu, Feb 14, 2013 at 2:24 AM, Avi Kessner <akessner@...> wrote: The math is too complicated for me to resolve easily. TheseIs it possible to redefine the question? You could gain confidence by testing the algorithm behaves as expected with given clock values, instead of having to guess (and have test failures when running the suite on a machine capable of more operations / tick). 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 needsIf I do not know what the result should be, I have to assume the computation provides the "correct" result. At this point I default to validating the computation - I don't know what the answer will be, but I know we have to be doing things "this" way. I feel bad resorting to this (it makes the software brittle and resistant to change), but if I can't check my work in the future because I don't know what the results should be, I have to guard the one source of truth I have (the algorithm). Cheers! Carl |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Amir Kolsky
Do you have the formulae or do you need to develop them?
From: testdrivendevelopment@... [mailto:testdrivendevelopment@...] On Behalf Of Avi Kessner Sent: Thursday, February 14, 2013 2:24 AM To: testdrivendevelopment@... Cc: robert Merkel Subject: Re: [TDD] How do you write tests if you aren't sure what the result should be? 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 |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Hi people!
English is not my mother tongue, so maybe I misunderstood some of your message, Avi. Review: - You have a program, you write it using TDD Ok? Then, - You have complicated formulas, already written, THAT ARE not in your program, that is, it's not part of what you are writing using TDD, it can be viewed as a math library you have. Your program will use that ALREADY written formulas. or? - You have complicated formulas, you must use and write in the next piece of your program Which is the case? I presume it is the second case, am I right? Then, you wrote 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?) WHY? Which is the use case in your program? I would start with a simple mini use case, then the formula(s) and their application will evolve in your program. Can you describe a use case? I could imagine one program: - I need to write a physics engine Instead of testing the results of a multibody gravity evaluation in a complicated environment, I would start with: - Given a ball, suspended in air, at time t0 its at y0, then I would test that at t1 its at y1 with y1 < y0 Angel "Java" Lopez @ajlopez gh:ajlopez On Thu, Feb 14, 2013 at 4:24 AM, Avi Kessner <akessner@...> wrote: ** [Non-text portions of this message have been removed] |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
My actual question is a meta-question by the way. How do I write testsYou can't. You need to compute by hand, or some other means, the expected result for some input. This should not be impossible. Check the result for simple cases. For instance, if I were writing a sin function, I would check sin(0) =0, sin(90)=1, and the like. Check examples from a textbook; compute the expected result with Mathematica or other mathematical software. OTOH, if the meta-question is how to *drive* development of a function with tests, perhaps i would break the function to be developed as a composition of functions, then test-drive those separately. Or maybe start with a crude approximation and then refine it as needed. Perhaps your customer does not need many significant digits. Perhaps you can get away with something that's only guaranteed to be within the expected order of magnitude. Or use a combination of both methods. Any way you look at it, to do TDD you need to be able to come up with examples of what the system should do given example inputs. Matteo |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
Donaldson, John
Avi, I don't think that's a simple question at all!
toggle quoted message
Show quoted text
I think it's hacking away at the boundary between TDD (a method) and algorithms (invention). John D. -----Original Message-----
From: testdrivendevelopment@... [mailto:testdrivendevelopment@...] On Behalf Of Avi Kessner Sent: 14 February 2013 08:24 To: testdrivendevelopment@... Cc: robert Merkel Subject: Re: [TDD] How do you write tests if you aren't sure what the result should be? 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 ------------------------------------ Yahoo! Groups Links |
Re: [TDD] How do you write tests if you aren't sure what the result should be?
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 |
Re: Request to participate in a research study regarding the performance appraisal of software testers.
Dear Members,
Thank you for supporting me in my research studies. Unfortunately we didn't receive enough response for this study. Hence we modified the study and made it a short and simple one. If you are a manager please visit the following link: Believe me, it won't take more than 15 minutes! Thank you for your help! Regards, -Tanjila ________________________________ From: Tanjila Kanij <tanjilakanij@...> To: "testdrivendevelopment@..." <testdrivendevelopment@...> Cc: robert Merkel <rmerkel@...> Sent: Wednesday, 5 September 2012, 10:57 Subject: Request to participate in a research study regarding the performance appraisal of software testers. Dear Members, I’m a PhD student in Faculty of Information and Communication Technologies, Swinburne University of Technology. As a project of my PhD thesis, my supervisorsProfessor John Grundy (jgrundy@...) and Dr. Robert Merkel (robert.merkel@...) and I (tkanij@...) are conducting a study to collect information about the current practice of performance appraisal of software testers in industry. We also plan to evaluate a proposed Performance Appraisal Form (PAF) for software testers. In this study, we hope to get responses from professionals who manage software testers. The project is approved by Swinburne University Human Research Ethics Subcommittee. The study is an online survey that should take around 40 minutes to complete. No association between your responses and any identifying details will be retained.After the successful completion of the survey we hope to have an idea of the state of the practice of performance appraisal of software testers, and will publish these results through peer-reviewed conferences and/or journals. This will benefit practitioners by informing them about broader industry practices for appraisal method, as well as benefiting research in the area to try and design better appraisal methods. The study will also validate a novel proposed Performance Appraisal Form (PAF) for testers. The validated PAF may be useful as a basis for appraising performance of testers in industry, as well as in academic research requiring performance assessment of testers. We invite managers of software testers to participate in the research study. As a manager your participation in the research study will add deep insight into the available knowledge on performance appraisal of software testers and will be helpful to evaluate the proposed performance appraisal form for testers. If you would like to participate or have further queries regarding the research study, please email me (tkanij@...). Best Regards Tanjila Kanij PhD candidate Faculty of Information and Communication Technologies Swinburne University of Technology. [Non-text portions of this message have been removed] |
Re: [TDD] Does TDD ask me to 'forget' all I know about software design?
sh wrote:
What are your experiences regarding the evolutional aspect of TDD whenI am responding a little late, so I hope this is still relevant. My best experience is the benefits of the small steps approach. In traditional design-first, the preconceptions and architectures are designed to protect you from design mistakes you won't see until it's too late. With TDD, mistakes slap you in the face immediately. Also, with superior test coverage, you can experiment with designs at will. So start your tests, lean towards what your guts say, and you'll see pretty soon if it was a good decision. If it wasn't, refactor. If it makes it worse, roll back and try again. We're talking about wasting minutes of time, not months. Or do you take the next smallest step and add a method "renderVertices"Yes, as described above, taking the next smallest step is vital. I catched a response about making the smallest test for the complete system. IMHO it does not matter if you start inside-out or outside-in. What matters is that you don't stretch out too far on either side and you build the "walking skeleton" as soon as possible. Does something like an eventSystem with listeners/dispatchers reallyI wouldn't care too much about the "impulse". Whatever it is, usually a gut feeling, the benefit is that you can try to refactor and introduce messaging at any time. Does it look better that way? Keep or roll back. Also, with large refactors, TDD and incremental refactoring techniques allow you to change designs one bit at a time while your app still keeps working, so there's really no stress involved. Michal Svoboda |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
On Thu, Jan 24, 2013 at 6:34 AM, John Goodsen <jgoodsen@...> wrote:
On Wed, Jan 23, 2013 at 4:14 PM, Charlie Poole <charliepoole@...I do part of my work in Ruby and I would not advise to patch a mock to anwrote:program, existing class just because I can. Mocks work well as a tool to design interfaces (or, in the case of dynamic languages, protocols.) Using Ruby's dynamic features to inject mocks in existing objects defeats this purpose; it's just a way to numb the pain of a design that is not right. The adapter can be thin or not, depending on my needs. What matters is that the adapter contains my decisions of how I want to use a certain API. Out of the 103 things it does I need perhaps just 5. The adapter is where I decide how to express those 5 things in terms of the other API. Matteo |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
John Goodsen
On Wed, Jan 23, 2013 at 4:14 PM, Charlie Poole <charliepoole@...>wrote:
so it boils down to (a) use the real object if you can and it's not a PIA or (b) write a thin adapter that you can mock in other tests. ... or (c) not discussed since it's Java - but if you were in a more dynamic language you'd just monkey patch a mock into the mix whenever you need it... why do you think the class is final anyways? -- John Goodsen RADSoft / Better Software Faster jgoodsen@... Lean/Kanban/XP/Scrum Coaching and Training Enterprise Ruby, Java and Scala Solutions |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
Hi,
toggle quoted message
Show quoted text
Regarding "making the code fit the test"... Your need to test has led you to consider an alternate structure involving an adapter. Now you have to ask yourself... would such an adapter improve the structure of the code, degrade it or is it neutral? If it's an improvement, then this is a good change, one that you were driven to make by the tests. If it's a bad change, you should probably not make it. I'd make this change myself because: 1. It improves testability, an important askect of design. 2. It decouples the presentation layer from the underlying logic, localizing it so that all the presentation code is in one place and opening the door to possible alternate presentation approaches in the future. 3. If correctly implemented, it only adds one thin adapter class. In summary, you make the code fit your concept of a well-designed program, following hints that you receive from the tests. Charlie On Wed, Jan 23, 2013 at 6:08 AM, sh <shvfn@...> wrote:
** |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
Matteo,
On 1/23/13 12:20 PM, Matteo Vaccari wrote: On Wed, Jan 23, 2013 at 5:27 PM, Tim Ottinger <tottinge@...> wrote:Having worked on IC development, I can say that's not always true. And there are definitely diagnostics to test that the electronics is constructed right, for testing prior to adding cost by packaging the chips.Ah. I get it.I agree in principle with Grenning, but there is a difference: the - George A software equivalent could be the technique of sanitizing the data-- ---------------------------------------------------------------------- * George Dinwiddie * Software Development Consultant and Coach ---------------------------------------------------------------------- |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
On Wed, Jan 23, 2013 at 5:27 PM, Tim Ottinger <tottinge@...> wrote:
Ah. I get it.I agree in principle with Grenning, but there is a difference: the diagnostics in electronics are not there to test the correctness of the electronics design; they are there to check if the electronics is damaged. A software equivalent could be the technique of sanitizing the data structures in memory in a long-running server. Matteo |
Re: [TDD] Howto mock a final object that doesn't offer an interface?
Pascal Roy
There's an interesting discussion there :
The objection I wanted to express is: I don't want to introducePerhaps, there would be value in exploring why people feel this way� What are the objections? I'm not disputing there may be valid objections behind that feeling, I am just curious to know what the real drivers are. If you accept the premise that testability is a critical or at least very important characteristic of what is good code, than any untested code becomes suspicious by nature. Writing production code even if just used to allow testability becomes a no-brainer, no? I like Tim's remarks on electronics. I think most everybody would agree electronics seem typically more reliable than software. At least, it feels that way to me. I think it has to do with the way they thing about testing the product, like making test points available at different critical points on the circuit boards. That's a pretty good analogy with what we're talking about here with the adapter... Pascal Le 2013-01-23 � 10:43, sh <shvfn@...> a crit : Hi Tim, |
to navigate to use esc to dismiss