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

Re: [TDD] End To End Test

pierre masci
 

Hi Esko,

i read the same book recently, and also found that it was hard to apply all
these new ideas on a project :
At each step there were so many questions, i had to keep on re-reading
parts of the book, and i was always scared to "do things wrong".
Making TDD katas has helped me understand how to do TDD practically, and
start to gain confidence.

You might want to watch a few Kata videos, like that one :

(or here, in other languages : )
There is also this website with lots of Katas proposed :


And/or these ones, where a teacher and his student comment their
pair-programming TDD sessions, to implement a Go game:
(in the Pairing Videos section)

And/or these : someone showing how s.he made a project with TDD, step by
step :

It takes some time, but it has been very teachful to me to watch some of
these simple practical examples, and practice a kata every day.
Now my brain and fingers start doing TDD by themselves, what we call
"muscle memory".

I hope this helps =o)
pierre / mascip


Re: End To End Test

xxtommo54xx
 

Great thanks guys for all the resources/ideas.

--- In testdrivendevelopment@..., "xxtommo54xx" <xxtommoxx@...> wrote:

Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to incorporate tdd into a sample project. Basically the project is an api that allows you to keep-alive various services, basically its a heartbeat. The book says to start out by designing a skeleton that is enough to get your application functioning and that which covers the core components. So the simplest end-to-end test I can think of is to send an http request and make sure the server received it. How should i structure this test? Should I have a fake http server and make a request to it and assert that the server received the request or should I just make a request to any arbitrary working url and get its return code?

I feel that my test case does not really cover the core components since the api has the ability to send keep alive requests to various services based on some various kinds trigger. Any suggestions on how to start?


Thanks.


Re: [TDD] End To End Test

 

xxtommo54xx wrote on 18.7.2012 0:25:
I'm new to tdd and i've read the book growing oo software. I'm trying to
incorporate tdd into a sample project. Basically the project is an api
that allows you to keep-alive various services, basically its a
heartbeat. The book says to start out by designing a skeleton that is
enough to get your application functioning and that which covers the
core components. So the simplest end-to-end test I can think of is to
send an http request and make sure the server received it. How should i
structure this test?
The people on this mailing list don't appear to do much end-to-end testing. It might be best that you ask your question on

--
Esko Luontola
www.orfjackal.net


Re: [TDD] Re: End To End Test

Osias Jota
 

+1

On 7/18/12, Adam Sroka <adam.sroka@...> wrote:
+1

Put another way: perhaps your real system is not as free as you think it
is. Anything that takes extra time or introduces uncertainty is not "free"
in the sense that it takes additional resources to test.

You can TDD with microtests and do just enough integration testing right
before you check in to convince yourself that you've got it. Or, you could
start by writing some tests to probe the real system and see how it behaves
with various timings. Then you use those findings to guide the initial set
of microtests.

On Tue, Jul 17, 2012 at 8:47 PM, Tim Ottinger <tottinge@...> wrote:

**


On Tue, Jul 17, 2012 at 10:16 PM, xxtommo54xx <xxtommoxx@...>
wrote:
Basically i am supposed to send a message to keep a connection that has
a timeout value alive. The message is dependent on the protocol being
used
i.e http, rmi, etc. It is also supposed to manage a set of these and send
the messages depending on some sort of event (ex. a timed trigger).

In the book they clearly outlined the core components for the skeletal
design which is the sniper communicating to a fake xmpp auction which
outputs the result to the ui.

I just have trouble identifying the core components for the skeleton
which is used to kickstart the tdd proccess and how to test it. Would i
be
able to use an actual implementation as opposed to a fake implementation
(like the fake auction server)? The book mentioned that one of the
reasons
they used a fake auction server was because querying the real auction
server was not free. In my case, i can test using a real resource for
free.
Any suggestions?

It depends. Under what circumstances is it okay for your test not to
pass? Do you want to run it when the server isn't running, or maybe
when you're in a train/plane/taxi/oxcart and don't have a good
internet connection?

I put a lot of stock in whether a test isolates failures, but when it
talks to external services (file system, web service, etc) it starts
to get fuzzy. It might fail without the code being wrong in certain
circumstances.

See this:
(free to read).

--
Tim Ottinger, Sr. Consultant, Industrial Logic
-------------------------------------










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

Yahoo! Groups Links



--
Osias, o Osias


Re: [TDD] Re: End To End Test

 

+1

Put another way: perhaps your real system is not as free as you think it
is. Anything that takes extra time or introduces uncertainty is not "free"
in the sense that it takes additional resources to test.

You can TDD with microtests and do just enough integration testing right
before you check in to convince yourself that you've got it. Or, you could
start by writing some tests to probe the real system and see how it behaves
with various timings. Then you use those findings to guide the initial set
of microtests.

On Tue, Jul 17, 2012 at 8:47 PM, Tim Ottinger <tottinge@...> wrote:

**


On Tue, Jul 17, 2012 at 10:16 PM, xxtommo54xx <xxtommoxx@...> wrote:
Basically i am supposed to send a message to keep a connection that has
a timeout value alive. The message is dependent on the protocol being used
i.e http, rmi, etc. It is also supposed to manage a set of these and send
the messages depending on some sort of event (ex. a timed trigger).

In the book they clearly outlined the core components for the skeletal
design which is the sniper communicating to a fake xmpp auction which
outputs the result to the ui.

I just have trouble identifying the core components for the skeleton
which is used to kickstart the tdd proccess and how to test it. Would i be
able to use an actual implementation as opposed to a fake implementation
(like the fake auction server)? The book mentioned that one of the reasons
they used a fake auction server was because querying the real auction
server was not free. In my case, i can test using a real resource for free.
Any suggestions?

It depends. Under what circumstances is it okay for your test not to
pass? Do you want to run it when the server isn't running, or maybe
when you're in a train/plane/taxi/oxcart and don't have a good
internet connection?

I put a lot of stock in whether a test isolates failures, but when it
talks to external services (file system, web service, etc) it starts
to get fuzzy. It might fail without the code being wrong in certain
circumstances.

See this:
(free to read).

--
Tim Ottinger, Sr. Consultant, Industrial Logic
-------------------------------------






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


Re: [TDD] Re: End To End Test

 

On Tue, Jul 17, 2012 at 10:16 PM, xxtommo54xx <xxtommoxx@...> wrote:
Basically i am supposed to send a message to keep a connection that has a timeout value alive. The message is dependent on the protocol being used i.e http, rmi, etc. It is also supposed to manage a set of these and send the messages depending on some sort of event (ex. a timed trigger).

In the book they clearly outlined the core components for the skeletal design which is the sniper communicating to a fake xmpp auction which outputs the result to the ui.

I just have trouble identifying the core components for the skeleton which is used to kickstart the tdd proccess and how to test it. Would i be able to use an actual implementation as opposed to a fake implementation (like the fake auction server)? The book mentioned that one of the reasons they used a fake auction server was because querying the real auction server was not free. In my case, i can test using a real resource for free. Any suggestions?
It depends. Under what circumstances is it okay for your test not to
pass? Do you want to run it when the server isn't running, or maybe
when you're in a train/plane/taxi/oxcart and don't have a good
internet connection?

I put a lot of stock in whether a test isolates failures, but when it
talks to external services (file system, web service, etc) it starts
to get fuzzy. It might fail without the code being wrong in certain
circumstances.

See this:
(free to read).



--
Tim Ottinger, Sr. Consultant, Industrial Logic
-------------------------------------



Re: End To End Test

xxtommo54xx
 

Basically i am supposed to send a message to keep a connection that has a timeout value alive. The message is dependent on the protocol being used i.e http, rmi, etc. It is also supposed to manage a set of these and send the messages depending on some sort of event (ex. a timed trigger).

In the book they clearly outlined the core components for the skeletal design which is the sniper communicating to a fake xmpp auction which outputs the result to the ui.

I just have trouble identifying the core components for the skeleton which is used to kickstart the tdd proccess and how to test it. Would i be able to use an actual implementation as opposed to a fake implementation (like the fake auction server)? The book mentioned that one of the reasons they used a fake auction server was because querying the real auction server was not free. In my case, i can test using a real resource for free. Any suggestions?

Thanks!

--- In testdrivendevelopment@..., "jmilkiewicz@..." <jmilkiewicz@...> wrote:

Hi

If i understand your use case correctly i would start with fake Http
server. This way you could easily record its behavior - even if you decide
to switch to "real http server"one day it would be quite useful to have
some fake http server with behavior you can easily define in your tests.
Basically i am thinking of some corner cases like server not avialable,
server responds too slow and so on.

br Jakub

2012/7/17 xxtommo54xx <xxtommoxx@...>

**


Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to
incorporate tdd into a sample project. Basically the project is an api that
allows you to keep-alive various services, basically its a heartbeat. The
book says to start out by designing a skeleton that is enough to get your
application functioning and that which covers the core components. So the
simplest end-to-end test I can think of is to send an http request and make
sure the server received it. How should i structure this test? Should I
have a fake http server and make a request to it and assert that the server
received the request or should I just make a request to any arbitrary
working url and get its return code?

I feel that my test case does not really cover the core components since
the api has the ability to send keep alive requests to various services
based on some various kinds trigger. Any suggestions on how to start?

Thanks.



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


Re: End To End Test

xxtommo54xx
 

Basically i am supposed to send a message to keep a connection that has a timeout value alive. The message is dependent on the protocol being used i.e http, rmi, etc. It is also supposed to manage a set of these and send the messages depending on some sort of event (ex. a timed trigger).

In the book they clearly outlined the core components for the skeletal design which is the sniper communicating to a fake xmpp auction which outputs the result to the ui.

I just have trouble identifying the core components for the skeleton which is used to kickstart the tdd proccess and how to test it. Would i be able to use an actual implementation as opposed to a fake implementation (like the fake auction server)? The book mentioned that one of the reasons they used a fake auction server was because querying the real auction server was not free. In my case, i can test using a real resource for free. Any suggestions?

Thanks!

--- In testdrivendevelopment@..., "jmilkiewicz@..." <jmilkiewicz@...> wrote:

Hi

If i understand your use case correctly i would start with fake Http
server. This way you could easily record its behavior - even if you decide
to switch to "real http server"one day it would be quite useful to have
some fake http server with behavior you can easily define in your tests.
Basically i am thinking of some corner cases like server not avialable,
server responds too slow and so on.

br Jakub

2012/7/17 xxtommo54xx <xxtommoxx@...>

**


Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to
incorporate tdd into a sample project. Basically the project is an api that
allows you to keep-alive various services, basically its a heartbeat. The
book says to start out by designing a skeleton that is enough to get your
application functioning and that which covers the core components. So the
simplest end-to-end test I can think of is to send an http request and make
sure the server received it. How should i structure this test? Should I
have a fake http server and make a request to it and assert that the server
received the request or should I just make a request to any arbitrary
working url and get its return code?

I feel that my test case does not really cover the core components since
the api has the ability to send keep alive requests to various services
based on some various kinds trigger. Any suggestions on how to start?

Thanks.



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


Re: [TDD] End To End Test

 

Hi

If i understand your use case correctly i would start with fake Http
server. This way you could easily record its behavior - even if you decide
to switch to "real http server"one day it would be quite useful to have
some fake http server with behavior you can easily define in your tests.
Basically i am thinking of some corner cases like server not avialable,
server responds too slow and so on.

br Jakub

2012/7/17 xxtommo54xx <xxtommoxx@...>

**


Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to
incorporate tdd into a sample project. Basically the project is an api that
allows you to keep-alive various services, basically its a heartbeat. The
book says to start out by designing a skeleton that is enough to get your
application functioning and that which covers the core components. So the
simplest end-to-end test I can think of is to send an http request and make
sure the server received it. How should i structure this test? Should I
have a fake http server and make a request to it and assert that the server
received the request or should I just make a request to any arbitrary
working url and get its return code?

I feel that my test case does not really cover the core components since
the api has the ability to send keep alive requests to various services
based on some various kinds trigger. Any suggestions on how to start?

Thanks.



Re: [TDD] End To End Test

 

Hi,

Are you writing an app which acts as an http client? If not, it's not clear to my why you would want to test sending an http request. Assume that any code you're not writing yourself works, and just worry about testing how you use it.

But then I don't understand what "an api that allows you to keep-alive" means. Can you describe your project in a bit more detail? Do you have some kind of program structure in mind?

Regards,
Russ

On Jul 17, 2012, at 5:25 PM, xxtommo54xx wrote:

Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to incorporate tdd into a sample project. Basically the project is an api that allows you to keep-alive various services, basically its a heartbeat. The book says to start out by designing a skeleton that is enough to get your application functioning and that which covers the core components. So the simplest end-to-end test I can think of is to send an http request and make sure the server received it. How should i structure this test? Should I have a fake http server and make a request to it and assert that the server received the request or should I just make a request to any arbitrary working url and get its return code?

I feel that my test case does not really cover the core components since the api has the ability to send keep alive requests to various services based on some various kinds trigger. Any suggestions on how to start?


Thanks.





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

Yahoo! Groups Links


-----------------
Come read my webnovel, Take a Lemon <>,
and listen to the Misfile radio play <>!


End To End Test

xxtommo54xx
 

Hi,

I'm new to tdd and i've read the book growing oo software. I'm trying to incorporate tdd into a sample project. Basically the project is an api that allows you to keep-alive various services, basically its a heartbeat. The book says to start out by designing a skeleton that is enough to get your application functioning and that which covers the core components. So the simplest end-to-end test I can think of is to send an http request and make sure the server received it. How should i structure this test? Should I have a fake http server and make a request to it and assert that the server received the request or should I just make a request to any arbitrary working url and get its return code?

I feel that my test case does not really cover the core components since the api has the ability to send keep alive requests to various services based on some various kinds trigger. Any suggestions on how to start?


Thanks.


Re: [TDD] Virtual Panel: Code-to-Test Ratios, TDD and BDD

 

The premise was quite interesting - see the answers to interesting and
important questions stacked up next to each other, and see the differences
in how people approach each problem.
Then I read the questions and was a bit dismayed on how shallow they were,
and really had no challenging thoughts or attempted to create any new
insights or drive the panelists into realms where they spoke on things they
hadn't spoken about 50 million times already.

Suggestion: next panel ask each panelist to provide three interesting
questions they would love the *other* panelists to answer. Hopefully things
the person(who is an expert) asking would like to know more about, or is
not sure/conflicted about. Otherwise, it just becomes link bait and SEO
fodder.


On Fri, Jul 13, 2012 at 7:46 PM, Josue Barbosa dos Santos <
josuesantos@...> wrote:

**


In the last couple of months several online discussions took place
about test first vs test last, code-to-test ratios or whether BDD is
really just TDD. InfoQ asked renown TDD and BDD experts to give us
their take on the usage of TDD, BDD and testing ratios.

The panelists:

J. B. Rainsberg - Consultant and TDD expert, blogs at The Code Whisperer
Dan North - Lean Technology Specialist at DRW Trading Group, coined
the term Behaviour Driven Development (BDD)
Gojko Adzic - Consultant, author of 'Specification by Example' and
'Bridging the Communication Gap'
Ron Jeffries - Independent consultant in XP and Agile methods, coached
the original XP project
Steve Freeman - Agile trainer and consultant, author of 'Growing
Object Oriented Software, Guided by Tests'

More here:



--
o,
Dz�



--
Thanks,

Roy Osherove

Author of "The Art Of Unit Testing" ( )
A blog for team leaders:
my .NET blog:
Twitter:
+972-524-655388 (GMT+2)



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


Virtual Panel: Code-to-Test Ratios, TDD and BDD

 

In the last couple of months several online discussions took place
about test first vs test last, code-to-test ratios or whether BDD is
really just TDD. InfoQ asked renown TDD and BDD experts to give us
their take on the usage of TDD, BDD and testing ratios.

The panelists:

J. B. Rainsberg - Consultant and TDD expert, blogs at The Code Whisperer
Dan North - Lean Technology Specialist at DRW Trading Group, coined
the term Behaviour Driven Development (BDD)
Gojko Adzic - Consultant, author of 'Specification by Example' and
'Bridging the Communication Gap'
Ron Jeffries - Independent consultant in XP and Agile methods, coached
the original XP project
Steve Freeman - Agile trainer and consultant, author of 'Growing
Object Oriented Software, Guided by Tests'

More here:



--
çDz,
Dzé


Re: Handling duplication was RE: [TDD] Cunningham quote about test-first

MarvinToll.com
 

Thank you Kay...

It was a chaotic road... and a fresh set of eyes is helpful... I'll get an updated posted this evening.

_Marvin

--- In testdrivendevelopment@..., "Kay A Pentecost" <kayp@...> wrote:

Hey, Edmund, How are you?

Thanks for calling out the single Assert and the fact that it can never
fail.

I think the first post I ever made to the XP list was something like "how do
you tell when your code is bad?

So I'm studying Code Smells and Refactoring now...

Because you brought it up, I looked at the code. It doesn't look like any
TDD code I've ever done, but what do I know?

So I've recognized "Large Class" which has too many instance variables, and
"Code Duplication."


There's are two "try" sections. They are identical except for the hard coded
primitive (I think that's the right word, is it?)
Here they are:
**
try {
// Use hard-coded 1 for assigned number of task threads.
SjcThreadLocalUtil.setUserId("Tasks [1] Create");
createTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Find");
findTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Update");
updateTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Query");
queryTasks(1);
clearCache();

**
And
try {
// Use assigned number of task threads.
SjcThreadLocalUtil.setUserId("Task [2] Create");
createTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Find");
findTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Update");
updateTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Query");
queryTasks(2);
clearCache();

This smells like Code Duplication to me. Any suggestions on refactoring?
I'm guessing a loop might work, but possibly not in this particular method.

Any suggestions??

Thanks,

Kay Pentecost


[TDD] Re: Cunningham quote about test-first

MarvinToll.com
 

... hmmm ... anytime we design a method aren't we "storyboarding a GUI"???

Said another way, as we move from worrying exclusively about whether the execution is "correct" to greater code understandability doesn't that distinguish 'unit testing' from 'unit designing'?

--- In testdrivendevelopment@..., Alan Baljeu <alanbaljeu@...> wrote:

So in fact we are talking about designing the user interface of a library (users being other programmers). And concurrently spiking the implementation to get a better idea of what kinds of things you can do. That's more like storyboarding a GUI than coding the guts of an application. Sounds like a fine approach to me.

Only to be clear with words, what you write to drive your API isn't called a test by anyone I've read. It's a driver or a fixture, or a demonstration. Tests are code that decide whether something is correct or not. They pass or fail something. TDD tests are tests in that sense. The "TDD is not about testing" holds because the testing process tries to judge whether an application is correct from a variety of angles while TDD tests aim to create code. It's not testing to Test the code only according to how it was created.

Alan Baljeu


Re: [TDD] The Art of Misdirection

 

Interesting. From the article:

You want each experiment to be inexpensive so you can try several. TDDing each option will work, sure, but it is going to be more expensive than just sketching something out to see if it feels right.
Really? I suppose it depends on what "just sketching something out" means. If he means, "do an informal object diagram" or "write a summary of the intended behavior" and he doesn't mean coding, I could see that. But that doesn't sound like what he's saying.

I think his basic assumption, here, is wrong:

You can sketch half-a-dozen ideas in the time it would take to TDD any one of them.

No. Actually, you can't. Not if by "sketch" he means "code it to demo quality" which is what he seems to be saying. I use TDD because I can code faster that way; I don't spend lots of time in the debugger, trying to figure out why my code doesn't work. I don't have to go back and figure out how i broke something that was working yesterday.

I agree. This is an excuse for Cowboy Coding, with a superior attitude, followed by a Legacy Code test-retrofit. No thanks.

On Jun 27, 2012, at 3:50 AM, Gishu Pillai wrote:

I read this a week or so ago. This is similar to the Lean Startup advice.

The premise being you do not know what is required. So you make an
assumption, quickly code it up, put it out there (production or a specific
slice of your users) and see if it moves your desired metrics or KPIs in
the right direction. If not, throw the code away. (The saving is the effort
you'd have wasted if you had TDDed an experiment which turned out to be the
wrong thing).

I did not get how this works if the experiment is a success. Is the advice
to throw the code away and then TDD a copy ? It appears that the prevalent
approach is to retrofit tests to it and improve the design.. also called
'stabilization'.

I can see how this can work with small teams with skilled programmers. In
enterprise-y contexts, I feel this would quickly deteriorate into cowboy
coding albeit with an agile hat. Adding tests to a 'demoed' feature will
usually take the back seat to the next cool feature to be added.. given a
sufficient dollop of timeline pressure.

I'd like to hear what the others feel...

On Tue, Jun 26, 2012 at 7:14 PM, Josue Barbosa dos Santos <
josuesantos@...> wrote:

**


People,

I think this link should
interest you once Dan North uses the TDD to construct his argument.

--
çDz,
Dzé


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



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



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

Yahoo! Groups Links


-----------------
Come read my webnovel, Take a Lemon <>,
and listen to the Misfile radio play <>!






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


Re: [TDD] The Art of Misdirection

 

I read this a week or so ago. This is similar to the Lean Startup advice.

The premise being you do not know what is required. So you make an
assumption, quickly code it up, put it out there (production or a specific
slice of your users) and see if it moves your desired metrics or KPIs in
the right direction. If not, throw the code away. (The saving is the effort
you'd have wasted if you had TDDed an experiment which turned out to be the
wrong thing).

I did not get how this works if the experiment is a success. Is the advice
to throw the code away and then TDD a copy ? It appears that the prevalent
approach is to retrofit tests to it and improve the design.. also called
'stabilization'.

I can see how this can work with small teams with skilled programmers. In
enterprise-y contexts, I feel this would quickly deteriorate into cowboy
coding albeit with an agile hat. Adding tests to a 'demoed' feature will
usually take the back seat to the next cool feature to be added.. given a
sufficient dollop of timeline pressure.

I'd like to hear what the others feel...

On Tue, Jun 26, 2012 at 7:14 PM, Josue Barbosa dos Santos <
josuesantos@...> wrote:

**


People,

I think this link should
interest you once Dan North uses the TDD to construct his argument.

--
o,
Dz�


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



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


Re: Handling duplication was RE: [TDD] Cunningham quote about test-first

 

Thank you!!

Kay

-----Original Message-----
From: testdrivendevelopment@...
[mailto:testdrivendevelopment@...] On Behalf Of Edmund
Schweppe
Sent: Tuesday, June 26, 2012 9:45 PM
To: testdrivendevelopment@...
Subject: Re: Handling duplication was RE: [TDD] Cunningham quote about
test-first


On Jun 26, 2012, at 8:02 PM, Kay A Pentecost wrote:

Hey, Edmund, How are you?

Thanks for calling out the single Assert and the fact that it can never
fail.

I think the first post I ever made to the XP list was something like
"how do
you tell when your code is bad?

So I'm studying Code Smells and Refactoring now...

Because you brought it up, I looked at the code. It doesn't look like
any
TDD code I've ever done, but what do I know?

So I've recognized "Large Class" which has too many instance variables,
and
"Code Duplication."
[ snip ]

This smells like Code Duplication to me. Any suggestions on refactoring?
I'm guessing a loop might work, but possibly not in this particular
method.

Any suggestions??

I spotted four try-finally blocks, three of which appear to be identical
except for the number of tasks. I'd probably first refactor the number of
tasks into a variable, extract the block into its own method, and promote
the variable to a method parameter. then I'd write three JUnit tests that
each call that new method, passing in the appropriate values (1, 2, and
BookingMultiCoreIT.NUMBER_OF_TASKS).

That's assuming, of course, that I didn't first try and find something
meaningful that I could Assert, rather than just store elapsed times in
local variables and dump them to System.out at the very end.

The fourth try-finally block calls the createRecursive(), findRecursive(),
etc. methods rather than the createTasks(), findTasks(), etc. methods. Off
the top of my head, I'm not sure how I'd handle that one; I'd probably
wait until I had a better understanding of what the heck the system under
test was supposed to be doing.


Edmund Schweppe
ed@...





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

Yahoo! Groups Links



Re: Handling duplication was RE: [TDD] Cunningham quote about test-first

 

On Jun 26, 2012, at 8:02 PM, Kay A Pentecost wrote:

Hey, Edmund, How are you?

Thanks for calling out the single Assert and the fact that it can never
fail.

I think the first post I ever made to the XP list was something like "how do
you tell when your code is bad?

So I'm studying Code Smells and Refactoring now...

Because you brought it up, I looked at the code. It doesn't look like any
TDD code I've ever done, but what do I know?

So I've recognized "Large Class" which has too many instance variables, and
"Code Duplication."
[ snip ]

This smells like Code Duplication to me. Any suggestions on refactoring?
I'm guessing a loop might work, but possibly not in this particular method.

Any suggestions??

I spotted four try-finally blocks, three of which appear to be identical except for the number of tasks. I'd probably first refactor the number of tasks into a variable, extract the block into its own method, and promote the variable to a method parameter. then I'd write three JUnit tests that each call that new method, passing in the appropriate values (1, 2, and BookingMultiCoreIT.NUMBER_OF_TASKS).

That's assuming, of course, that I didn't first try and find something meaningful that I could Assert, rather than just store elapsed times in local variables and dump them to System.out at the very end.

The fourth try-finally block calls the createRecursive(), findRecursive(), etc. methods rather than the createTasks(), findTasks(), etc. methods. Off the top of my head, I'm not sure how I'd handle that one; I'd probably wait until I had a better understanding of what the heck the system under test was supposed to be doing.


Edmund Schweppe
ed@...


Handling duplication was RE: [TDD] Cunningham quote about test-first

 

Hey, Edmund, How are you?

Thanks for calling out the single Assert and the fact that it can never
fail.

I think the first post I ever made to the XP list was something like "how do
you tell when your code is bad?

So I'm studying Code Smells and Refactoring now...

Because you brought it up, I looked at the code. It doesn't look like any
TDD code I've ever done, but what do I know?

So I've recognized "Large Class" which has too many instance variables, and
"Code Duplication."


There's are two "try" sections. They are identical except for the hard coded
primitive (I think that's the right word, is it?)
Here they are:
**
try {
// Use hard-coded 1 for assigned number of task threads.
SjcThreadLocalUtil.setUserId("Tasks [1] Create");
createTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Find");
findTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Update");
updateTasks(1);
clearCache();

SjcThreadLocalUtil.setUserId("Tasks [1] Query");
queryTasks(1);
clearCache();

**
And
try {
// Use assigned number of task threads.
SjcThreadLocalUtil.setUserId("Task [2] Create");
createTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Find");
findTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Update");
updateTasks(2);
clearCache();

SjcThreadLocalUtil.setUserId("Task [2] Query");
queryTasks(2);
clearCache();

This smells like Code Duplication to me. Any suggestions on refactoring?
I'm guessing a loop might work, but possibly not in this particular method.

Any suggestions??

Thanks,

Kay Pentecost

-----Original Message-----
From: testdrivendevelopment@...
[mailto:testdrivendevelopment@...] On Behalf Of Edmund
Schweppe
Sent: Tuesday, June 26, 2012 3:16 PM
To: testdrivendevelopment@...
Subject: Re: [TDD] Cunningham quote about test-first

<snip>

test/info/soaj/sjr/business/facade/BookingMultiCoreIT.html

I'm glad that you found developing that code to be significant (and, I
presume, useful) to you.

I further presume that you did not develop that code using TDD, as there
is only one "test" method in the 635 lines of code, and that one test
method cannot possibly fail. There is only one assertion, and the method
whose return value is being checked has a hardcoded return value of
"true".