¿ªÔÆÌåÓý

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

Getting back into C# testing

 

I've been away from serious OOP programming for a while, working in Prolog, etc. ?So now I'm back, using VS2013, and starting development with a large CAD API. ?

My TDD experience has followed the old data-oriented style, testing whether a function causes the right kinds of objects to be produced, rather than testing that it invokes the right methods. ?(It makes more sense to me, that my concern is to construct the correct and very visible model, and not how that model was constructed.)

So now, given this brand-new API (which I know is well made and stable), is it a good idea to create my own classes to wrap access to the API, or is it better just to access the API directly?

Following the TDD mantra of test-first, I'm thinking about:
{
? setup the test scenario.
? do something interesting.
? check what happened.
}

I write the above in natural fashion, and then build classes and methods to match that fashion, and link those to the underlying API.

Does this all make sense? ?Shall I use the built-in test framework? ?Are there any valued innovations in the last years about software development?
?
Alan Baljeu


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Starting with acceptance tests is a great idea. So is starting with high level unit tests, mocking the details, and then working your way down. Also, sometimes if I think I know what the essence of the problem is I will start there, or if I'm not even sure how I am going to do it I may just pick something to spike.?

Any of these techniques, or a combination, can be used with a given story. TMTOWTDI

On Thursday, August 28, 2014, George Dinwiddie lists@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

Michal,

On 8/28/14 12:03 PM, Michal Svoboda pht@...
[testdrivendevelopment] wrote:
> Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
>> When the entire test is written up front (for a new class at least)
>> the test will fail, because a failure to compile is considered a
>> failure. The problem that I have with the approach is that when it
>> "passes", does it pass for the right reason? Or, do we have
>> unnecessary test code? or production code? Did the test ever fail for
>> the expected reason, or did it fail only in the form of a compilation
>> failure?
>
> Hi Kaleb,
>
> I hear what you are saying. But it really goes down to that gut feeling.
> Sometimes I want to see the whole story first, not just "once upon a
> time there was an object". It usually depends on what level of certainty
> I feel over my requirements. The objective is to drive the design with
> the test, not to just write it first.

I write acceptance tests all at once. I write unit tests a bit at a
time, often starting with the creation of a new object whose definition
does not yet exist. In this fashion I work inside-out within the bounds
of outside-in.

> Even if the test is written in a bigger chunk, you can still add in the
> code one bit at a time and see the test fail for various reasons until
> you get (and subsequently fix) the desired one.

With effort, you can. But how does that drive the design?

- George

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


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Michal,

On 8/28/14 12:03 PM, Michal Svoboda pht@... [testdrivendevelopment] wrote:
Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
When the entire test is written up front (for a new class at least)
the test will fail, because a failure to compile is considered a
failure. The problem that I have with the approach is that when it
"passes", does it pass for the right reason? Or, do we have
unnecessary test code? or production code? Did the test ever fail for
the expected reason, or did it fail only in the form of a compilation
failure?
Hi Kaleb,

I hear what you are saying. But it really goes down to that gut feeling.
Sometimes I want to see the whole story first, not just "once upon a
time there was an object". It usually depends on what level of certainty
I feel over my requirements. The objective is to drive the design with
the test, not to just write it first.
I write acceptance tests all at once. I write unit tests a bit at a time, often starting with the creation of a new object whose definition does not yet exist. In this fashion I work inside-out within the bounds of outside-in.

Even if the test is written in a bigger chunk, you can still add in the
code one bit at a time and see the test fail for various reasons until
you get (and subsequently fix) the desired one.
With effort, you can. But how does that drive the design?

- George

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


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
When the entire test is written up front (for a new class at least)
the test will fail, because a failure to compile is considered a
failure. The problem that I have with the approach is that when it
"passes", does it pass for the right reason? Or, do we have
unnecessary test code? or production code? Did the test ever fail for
the expected reason, or did it fail only in the form of a compilation
failure?
Hi Kaleb,

I hear what you are saying. But it really goes down to that gut feeling.
Sometimes I want to see the whole story first, not just "once upon a
time there was an object". It usually depends on what level of certainty
I feel over my requirements. The objective is to drive the design with
the test, not to just write it first.

Even if the test is written in a bigger chunk, you can still add in the
code one bit at a time and see the test fail for various reasons until
you get (and subsequently fix) the desired one.

Cheers,
Michal


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 


On Thu, Aug 28, 2014 at 8:53 AM, Colin Vipurs zodiaczx6@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:
I had never thought about calling a single method on the SUT multiple times as duplication. I'll have to spend some more time thinking about that.
Perhaps I should write this up somewhere. ?The usual example I give when teaching is using Java and moving a method from a static call no a non-static call. ?The test suite now needs to be updated in multiple places, hence the duplication.

Please do. Feel free to e-mail me or post a link to the writeup once it's done :).

--Kaleb


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 


On Thu, Aug 28, 2014 at 8:38 AM, 'Donaldson, John' john.m.donaldson@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:
If you insist (as an earlier poster did) that you first write an assert, then you would avoid this ¡°compilation only¡± worry (as long as your assert is non-trivial).

I remember seeing that post but I forgot to respond -- that's a good idea that I've never tried. Done properly that should provide the necessary guarantees.

Thanks for re-pointing that out.

--Kaleb


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Hi Kaleb,

As others have said: Change gear depending on your experience wit TDD and comfort in the situation.

There's a another point to be made though. Ron and Chet emphasized in their CSD training that TDD has two 'modes': design and implementation. When you write a new test, it usually introduces some sort of new concept in the system. You can write more than one line, even if the first line doesn't compile, if that helps you see what the interface/design should look like. When you have something you like, you make sure it compiles, but fails. Then you start with the implementation mode, and make it work.

If there are more than one or two new concepts introduced in one test, I'd wonder if the test is maybe a little to broad in scope, and I should take a smaller steps.

Wouter


On Tue, Aug 26, 2014 at 5:48 PM, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

Over the last three years I've been doing training on and advocating TDD where I work and a number of people have been striving to learn and use TDD in their daily development :).

--- An experience with coworker 1 ---

One of these coworkers recently published a 6-part series on TDD that starts off assuming no prior experience with TDD ().

In part two, having recently introduced the three laws of TDD, he wrote the following ():

[Test]

public?void?Execute_delegates_to_IWidgetLoader_to_load_widget_details()

{

? ? var?activator?=?new?WidgetActivator();

?}


At this point the test fails because WidgetActivator doesn't exist. He then proceeds to introduce a dependency and a constructor parameter before making the test pass:

var?mockWidgetLoader?=?new?Mock<IWidgetLoader>();
var?activator?=?new?WidgetActivator(mockWidgetLoader.Object);

When a commenter pointed out that he was violating the three laws of TDD of he commented:

"When adding a new test, you do not stop as soon as it turns red; rather you stop when the test is completely written. Then you labor to make that test turn green by modfiying [sic] the class-under-test. Think about it this way: if you write a partial test then make it go green, you now have a passing test *that is wrong*. A test should be green if and only if it is valid."

I disagree with the comment because it allows multiple unnecessary lines of code to be written and doesn't provide a progression that guarantees that all production code is effectively "tested"/covered. It also makes it harder to get feedback from the test about the design of the system. Sure, the developer might tweak the test code to improve the API but at that point the API design isn't supported by a working implementation so it's not necessarily going to reveal design defects as quickly.

Another person pointed out that "an incomplete but green test is at best misleading and at worst wrong: if a test is green it should be a valid test, and a partial or incomplete test is not valid."

--- An experience with coworker 2 ---

Coworker 2 recently came to me with some questions. He described his process wherein he would:

* Create an empty test
* Add a variable assignment: var instance = new MyClass();
* Introduce the class
* Add dependency1 to that class: var instance = new MyClass(dep1);
* Add that dependency as a constructor parameter
* Add dependency2 to that class: var instance = new MyClass(dep1, dep2);
* Call the method to be under test: var result = instance.Execute();
* Define the method under test
* Add a parameter to the callsite of the method under test: var result = instance.Execute(param1);
* Add the new parameter to the implementation of the method under test
* Add another parameter to the callsite of the method under test: var result = instance.Execute(p1, p2);
* ...

The story, in short, is that no matter what he was doing extremely small steps -- steps that felt unnaturally small to me. Ultimately he had a number of problems which seemed to be because he wasn't letting the tests guide the implementation but he felt the implementation went really slowly because after writing a fair amount of code and he'd have to come back and modify many of his tests when a new parameter to a method needed to be added.?

I introduced him to ATDD/double-loop TDD in hopes that it'd help him work in vertical slices, let the system evolve, and help him discover the required parameters/dependencies early in the process.

--- Questions ---

Both of the above experiences and questions go back to understanding the three laws of TDD and step size. As I'm entirely self taught, I'd like to know your thoughts.

Do you strictly follow the three laws of TDD as literally written?
What step size do you typically have when going back and forth between tests and code?
How do you decide the appropriate step size?
When writing a test, do you define a method or constructor with all its expected parameters?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

Thank you for the feedback.

--Kaleb




--
Wouter Lagerweij ? ? ? ? ?|?wouter@...
? |
| +31(0)6 28553506


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

I had never thought about calling a single method on the SUT multiple times as duplication. I'll have to spend some more time thinking about that.
Perhaps I should write this up somewhere. ?The usual example I give when teaching is using Java and moving a method from a static call no a non-static call. ?The test suite now needs to be updated in multiple places, hence the duplication.

If the entire test is written up front, and a new class is under development, that test will fail because of a failure to compile. The author could in theory, write lots of production code and then see the test "pass" without ever having seen it fail for the expected reasons. I would hope that wouldn't happen, but not having seen the full development progress or the progression taken it's a concern that I have.


I get you now. ?In my head I see this as two forms of failure, compilation failure and runtime failure. ?I won't even run the test if the compiler is complaining*. ?The key here really is to always see the test fail /for the right reason/, i.e. the diagnostic output of my assert. ?It's good practise to ensure your diagnostics messages convey all the information you want them to at this point anyway.

* At least in a language/IDE that offers good support?


Re: [TDD] Three Law of TDD - to strictly follow, or not?

Donaldson, John
 

¿ªÔÆÌåÓý

Kaleb,

?

If you insist (as an earlier poster did) that you first write an assert, then you would avoid this ¡°compilation only¡± worry (as long as your assert is non-trivial).

?

John D.

?

From: testdrivendevelopment@... [mailto:testdrivendevelopment@...]
Sent: 28 August 2014 16:27
To: testdrivendevelopment@...
Subject: Re: [TDD] Three Law of TDD - to strictly follow, or not?

?




?

On Tue, Aug 26, 2014 at 12:33 PM, Michal Svoboda pht@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

> Do you consider, "an incomplete but green test is at best misleading
> and at worst wrong"?

A test is only wrong in case you have never seen it fail. All other
tests are complete and functional. As for misleading, that depends how
good a story the test tells. Tests can lie or drift apart from reality.
Usually that is more likely when the test uses mocks.


I think you've just described my biggest concern with writing the entire test up front. When the entire test is written up front (for a new class at least) the test will fail, because a failure to compile is considered a failure. The problem that I have with the approach is that when it "passes", does it pass for the right reason? Or, do we have unnecessary test code? or production code? Did the test ever fail for the expected reason, or did it fail only in the form of a compilation failure?

?

--Kaleb





Re: [TDD] Three Law of TDD - to strictly follow, or not?

 


On Wed, Aug 27, 2014 at 8:23 AM, Colin Vipurs zodiaczx6@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

> This is something I will let evolve as I add more tests. ?It seems like the pain your coworker was feeling could be down to not refactoring the test itself. ?Instantiating the class under test multiple times in a test is what I would consider to be duplication
?
In some ways you're exactly correct. He could have used a factory method to extract out duplication in the creation code. But at other times no. He would sometimes write 15 tests for a method and then add a new parameter to the method under test resulting in the need to modify 15 tests. I believe he was doing too much iceberg testing -- that is, he was trying to test an "iceberg" through a small whole rather than testing the individual methods. He hadn't yet tied in how SRP and small units improve the overall TDD experience.

Again I would put that down to duplication. ?It's extreme, but if I call a method from 15 tests I see that as something that should be extracted.

I had never thought about calling a single method on the SUT multiple times as duplication. I'll have to spend some more time thinking about that.
?

1) Assuming each test has some setup -- each of those lines in the test needs to be "tested". In other words, we should be able to see a failure indicating that line in the test is necessary. If we have not seen the "failure" it's possible that we have made an error in the setup which increases the likelihood that we'll have to debug the test.

I'm not sure I'm following you here. ?Doesn't the failing test diagnostics provide this information/guarantee?

I responded to another of your e-mails a little bit ago that I think explains better, but I'll describe it again here.

If the entire test is written up front, and a new class is under development, that test will fail because of a failure to compile. The author could in theory, write lots of production code and then see the test "pass" without ever having seen it fail for the expected reasons. I would hope that wouldn't happen, but not having seen the full development progress or the progression taken it's a concern that I have.

--Kaleb


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 


On Tue, Aug 26, 2014 at 12:33 PM, Michal Svoboda pht@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:
> Do you consider, "an incomplete but green test is at best misleading
> and at worst wrong"?

A test is only wrong in case you have never seen it fail. All other
tests are complete and functional. As for misleading, that depends how
good a story the test tells. Tests can lie or drift apart from reality.
Usually that is more likely when the test uses mocks.

I think you've just described my biggest concern with writing the entire test up front. When the entire test is written up front (for a new class at least) the test will fail, because a failure to compile is considered a failure. The problem that I have with the approach is that when it "passes", does it pass for the right reason? Or, do we have unnecessary test code? or production code? Did the test ever fail for the expected reason, or did it fail only in the form of a compilation failure?

--Kaleb


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Thanks for the feedback Jeff.

In thinking about "green" tests and the process taken with TDD, I think it boils down to the fact that the name of the test should represent the goal for the test. Along the way the test will be green: it'll be green when you've just introduced a class and the test compiles for the first time; it'll be green when you've introduced the second test and still have duplication to extract out. It'll be green many times along the way but until the purpose of the test is met, i.e., until the test matches its description fully, it is incomplete... and that's alright.

--Kaleb


On Tue, Aug 26, 2014 at 11:31 AM, Jeff Langr jeff@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:



Hi Kaleb,

Regarding "an incomplete but green test is at best misleading and at worst wrong: if a test is green it should be a valid test, and a partial or incomplete test is not valid."

... If I think about using, say, a tool like Infinitest that is constantly running tests, it reports green against "incomplete" tests, and I'm ok with that. So I don't think it's "wrong" per se.

I've both strictly followed the three laws and not. For me, it depends upon tools and problem at hand, as others have suggested. Mostly, I fix things that are obvious problems at the earliest possible opportunity rather than wait, but I'm not dogmatic about it.

Jeff

Langr Software Solutions, Inc.


Modern C++ Programming with TDD ()
Agile in a Flash ()
Agile Java: Crafting Code with Test-Driven Development
? ()

On Tue, Aug 26, 2014 at 9:48 AM, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:


Over the last three years I've been doing training on and advocating TDD where I work and a number of people have been striving to learn and use TDD in their daily development :).

--- An experience with coworker 1 ---

One of these coworkers recently published a 6-part series on TDD that starts off assuming no prior experience with TDD ().

In part two, having recently introduced the three laws of TDD, he wrote the following ():

[Test]

public?void?Execute_delegates_to_IWidgetLoader_to_load_widget_details()

{

? ? var?activator?=?new?WidgetActivator();

?}


At this point the test fails because WidgetActivator doesn't exist. He then proceeds to introduce a dependency and a constructor parameter before making the test pass:

var?mockWidgetLoader?=?new?Mock<IWidgetLoader>();
var?activator?=?new?WidgetActivator(mockWidgetLoader.Object);

When a commenter pointed out that he was violating the three laws of TDD of he commented:

"When adding a new test, you do not stop as soon as it turns red; rather you stop when the test is completely written. Then you labor to make that test turn green by modfiying [sic] the class-under-test. Think about it this way: if you write a partial test then make it go green, you now have a passing test *that is wrong*. A test should be green if and only if it is valid."

I disagree with the comment because it allows multiple unnecessary lines of code to be written and doesn't provide a progression that guarantees that all production code is effectively "tested"/covered. It also makes it harder to get feedback from the test about the design of the system. Sure, the developer might tweak the test code to improve the API but at that point the API design isn't supported by a working implementation so it's not necessarily going to reveal design defects as quickly.

Another person pointed out that "an incomplete but green test is at best misleading and at worst wrong: if a test is green it should be a valid test, and a partial or incomplete test is not valid."

--- An experience with coworker 2 ---

Coworker 2 recently came to me with some questions. He described his process wherein he would:

* Create an empty test
* Add a variable assignment: var instance = new MyClass();
* Introduce the class
* Add dependency1 to that class: var instance = new MyClass(dep1);
* Add that dependency as a constructor parameter
* Add dependency2 to that class: var instance = new MyClass(dep1, dep2);
* Call the method to be under test: var result = instance.Execute();
* Define the method under test
* Add a parameter to the callsite of the method under test: var result = instance.Execute(param1);
* Add the new parameter to the implementation of the method under test
* Add another parameter to the callsite of the method under test: var result = instance.Execute(p1, p2);
* ...

The story, in short, is that no matter what he was doing extremely small steps -- steps that felt unnaturally small to me. Ultimately he had a number of problems which seemed to be because he wasn't letting the tests guide the implementation but he felt the implementation went really slowly because after writing a fair amount of code and he'd have to come back and modify many of his tests when a new parameter to a method needed to be added.?

I introduced him to ATDD/double-loop TDD in hopes that it'd help him work in vertical slices, let the system evolve, and help him discover the required parameters/dependencies early in the process.

--- Questions ---

Both of the above experiences and questions go back to understanding the three laws of TDD and step size. As I'm entirely self taught, I'd like to know your thoughts.

Do you strictly follow the three laws of TDD as literally written?
What step size do you typically have when going back and forth between tests and code?
How do you decide the appropriate step size?
When writing a test, do you define a method or constructor with all its expected parameters?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

Thank you for the feedback.

--Kaleb







Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Answers inline.

> This is something I will let evolve as I add more tests. ?It seems like the pain your coworker was feeling could be down to not refactoring the test itself. ?Instantiating the class under test multiple times in a test is what I would consider to be duplication
?
In some ways you're exactly correct. He could have used a factory method to extract out duplication in the creation code. But at other times no. He would sometimes write 15 tests for a method and then add a new parameter to the method under test resulting in the need to modify 15 tests. I believe he was doing too much iceberg testing -- that is, he was trying to test an "iceberg" through a small whole rather than testing the individual methods. He hadn't yet tied in how SRP and small units improve the overall TDD experience.

Again I would put that down to duplication. ?It's extreme, but if I call a method from 15 tests I see that as something that should be extracted.

1) Assuming each test has some setup -- each of those lines in the test needs to be "tested". In other words, we should be able to see a failure indicating that line in the test is necessary. If we have not seen the "failure" it's possible that we have made an error in the setup which increases the likelihood that we'll have to debug the test.

I'm not sure I'm following you here. ?Doesn't the failing test diagnostics provide this information/guarantee?

2) When we write the whole test without having supported it with the necessary production code, the production code, though testable, will not have had the same opportunity to evolve as it would have had it been co-developed with the tests. To put this another way and refer to J.B. Rainsberger's Queueing Theory post, we've lost the feedback loop between each line in the test and the production code. IMO, when we write the entirety of the test before writing any production code we're more likely to mentally create a design and go with it rather than letting it evolve fluidly.

3) When we don't co-develop the production code with the tests, we've also elongated the time between having a passing unit test and the corresponding implementation which again increases the likelihood that we'll need to debug something or attempt a jump that's too big.


I think both of these come down to how big your tests are and how much functionality they're attempting to test in a single go. ?To draw an example, imagine I have a class that converts object A into object B - i will have 1 test for each and every field and incrementally add the conversion as I go.


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

I would always do this when leaving for the day, mostly as a way of reminding myself in the morning what I was working on


On Wed, Aug 27, 2014 at 2:48 PM, Charlie Poole charliepoole@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

A rule of thumb I followed for many years was to leave a failing test when taking a break.

Charlie

On Aug 27, 2014 6:41 AM, "Tim Ottinger tottinge@... [testdrivendevelopment]" <testdrivendevelopment@...> wrote:
?

Never trust a test you have never seen fall.

Tests can pass for the wrong reasons.

You have to trust then or get rid of them.

That said, there are intermediate steps which are legitimately green on your way to completing a more significant goal.

That only leaves a few little procedural questions.

How long does it remain incomplete?

How do you denote that it is incomplete?

How do you website you don't abandon it?

Most of the time you work one test to completion before check-in or taking a break so it is a non-issue.

But if you are forced to leave our for a while, these things matter.

On Aug 27, 2014 3:09 AM, "Samuel ?slund samuel@... [testdrivendevelopment]" <testdrivendevelopment@...> wrote:


On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel





--
Maybe she awoke to see the roommate's boyfriend swinging from the chandelier wearing a boar's head.

Something which you, I, and everyone else would call "Tuesday", of course.


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

A rule of thumb I followed for many years was to leave a failing test when taking a break.

Charlie

On Aug 27, 2014 6:41 AM, "Tim Ottinger tottinge@... [testdrivendevelopment]" <testdrivendevelopment@...> wrote:

?

Never trust a test you have never seen fall.

Tests can pass for the wrong reasons.

You have to trust then or get rid of them.

That said, there are intermediate steps which are legitimately green on your way to completing a more significant goal.

That only leaves a few little procedural questions.

How long does it remain incomplete?

How do you denote that it is incomplete?

How do you website you don't abandon it?

Most of the time you work one test to completion before check-in or taking a break so it is a non-issue.

But if you are forced to leave our for a while, these things matter.

On Aug 27, 2014 3:09 AM, "Samuel ?slund samuel@... [testdrivendevelopment]" <testdrivendevelopment@...> wrote:


On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel



Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Never trust a test you have never seen fall.

Tests can pass for the wrong reasons.

You have to trust then or get rid of them.

That said, there are intermediate steps which are legitimately green on your way to completing a more significant goal.

That only leaves a few little procedural questions.

How long does it remain incomplete?

How do you denote that it is incomplete?

How do you website you don't abandon it?

Most of the time you work one test to completion before check-in or taking a break so it is a non-issue.

But if you are forced to leave our for a while, these things matter.

On Aug 27, 2014 3:09 AM, "Samuel ?slund samuel@... [testdrivendevelopment]" <testdrivendevelopment@...> wrote:



On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel



Re: [TDD] Three Law of TDD - to strictly follow, or not?

Donaldson, John
 

¿ªÔÆÌåÓý

I think all the answers have been wise and sensible. But then, I think the answers all come from ¡°Ha¡± or ¡°Ri¡± practitioners, and I suspect Kaleb was talking to ¡°Shu¡± people.

(If you are wondering what I am talking about, there¡¯s a concise explanation of ¡°ShuHaRi¡± here: )

?

I¡¯d really like a beginner to try to stick to three rules pretty strictly, with the probably addition of Samuel¡¯s ¡°Commit¡±.

?

John D.

?

From: testdrivendevelopment@... [mailto:testdrivendevelopment@...]
Sent: 27 August 2014 14:55
To: testdrivendevelopment@...
Subject: Re: [TDD] Three Law of TDD - to strictly follow, or not?

?




Exactly. You should only commit the test after you've gone through the full Red-Green-Refactor. In fact, assuming you're using DVCS or your own branch, I would go so far as to say that you should always Red-Green-Refactor-Commit. I've written more on this here:

?

?

On Wed, Aug 27, 2014 at 4:09 AM, Samuel ?slund samuel@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:

?

Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel




--
Steve Smith





Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Exactly. You should only commit the test after you've gone through the full Red-Green-Refactor. In fact, assuming you're using DVCS or your own branch, I would go so far as to say that you should always Red-Green-Refactor-Commit. I've written more on this here:



On Wed, Aug 27, 2014 at 4:09 AM, Samuel ?slund samuel@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel




--
Steve Smith


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

¿ªÔÆÌåÓý

On 14/8/26 17:48, Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
?
Do you consider, "an incomplete but green test is at best misleading and at worst wrong"?

You might want to consider the difference between a test during development locally and a test that have been checked in to the common repository.

I have been confused by tests with names saying they check something that is not checked, making me spend time searching for problem in the wrong place.
On the other hand during TDD it is rather important to know that the test actually fails, like you and others describe. The key as I see it is if the test is committed or not. Mostly the tests confusing me have come from being interupted while they happened to be green and then missing that they was not compete when coming back.

Regards,
//Samuel


Re: [TDD] Three Law of TDD - to strictly follow, or not?

 

Kaleb Pederson kaleb.pederson@... [testdrivendevelopment] wrote:
Do you strictly follow the three laws of TDD as literally written?
What step size do you typically have when going back and forth between
tests and code? How do you decide the appropriate step size?
Either approach you described can be justified.

Test that just contains one variable is actually complete and says "the
object can be constructed this way". Remember there is an implied "this
does not fail" even if there are no asserts.

In the classic cycle, you would then proceed to write another test, that
tells a different story. Then, in the refactor phase, you'd maybe remove
the first test.

From my experience indeed sometimes you want to go so slow that this is
useful. Other times not. In absence of gut feeling, do baby steps.

Also, in non-strict typed languages (i.e. javascript) a test that just
describes object construction syntax could be useful.

Do you consider, "an incomplete but green test is at best misleading
and at worst wrong"?
A test is only wrong in case you have never seen it fail. All other
tests are complete and functional. As for misleading, that depends how
good a story the test tells. Tests can lie or drift apart from reality.
Usually that is more likely when the test uses mocks.

Michal