Should is the new Must?

Why did 'should' become the going nomenclature of BDD framworks?

'Should' connotes 'ought', as if something ought to do xyz, but
doesn't necessarily have to. I don't know about you, but I don't write
my tests/specs that way!

'Must' is the word that denotes what our tests/specs do.

  my_method.must.do_the_right_thing

not

  my_method.should.do_the_right_thing

'Must' is a shorter word too. So why didn't it become the word of
choice here?

I think long dead Grammar teachers are rolling in their graves.

-7. Muse.

Trans wrote:

Why did 'should' become the going nomenclature of BDD framworks?

'Should' connotes 'ought', as if something ought to do xyz, but
doesn't necessarily have to. I don't know about you, but I don't write
my tests/specs that way!

'Must' is the word that denotes what our tests/specs do.

I agree. I've suggested the classic requirement-docs' "shall" in the past too, but "must" has an immediacy more appropriate to BDD.

- Charlie

Hi,

···

On Nov 18, 2008, at 7:09 AM, Trans wrote:

Why did 'should' become the going nomenclature of BDD framworks?

'Should' connotes 'ought', as if something ought to do xyz, but
doesn't necessarily have to. I don't know about you, but I don't write
my tests/specs that way!

'Must' is the word that denotes what our tests/specs do.

my_method.must.do_the_right_thing

not

my_method.should.do_the_right_thing

'Must' is a shorter word too. So why didn't it become the word of
choice here?

Perhaps because even we programmers are fallible, and it softens the blow when specs fail. Ah! "my_method" is acting up again!

Stephen

Dunno. Don't care. I don't feel the need for DSL-y notation in my
tests.

assert_rocks(Test::Unit) # Test::Unit 2 anyway

Regards,

Dan

···

On Nov 18, 6:09 am, Trans <transf...@gmail.com> wrote:

Why did 'should' become the going nomenclature of BDD framworks?

Because that's the word PMs and clients typically use when they are
describing a system, and BDD attempts to eliminate vocabulary
differences between the client and the programmer.

True, they sometimes say "must", when they really want to emphasize
something. But for the most part they say things like "after the user
logs in they should be shown a list of overdue frobbits, if there are
any".

···

On Tue, Nov 18, 2008 at 8:09 AM, Trans <transfire@gmail.com> wrote:

Why did 'should' become the going nomenclature of BDD framworks?

--
Avdi

But you are setting up an expectation, right?

my_method.must.do_the_right_thing.
it didn't? but it must!

my_method.should.do_the_right_thing.
it didn't, but it should!

For me the second example feels more natural in a environment where you expect tests to fail at first, maybe this is different in BDD than in TDD, I don't know enough about BDD. Especially when you use tests to design interfaces the "should" thinking comes more natural: You don't have a feature yet but you write down what it should do, then you implement it.

···

On 18.11.2008, at 13:30 , Charles Oliver Nutter wrote:

Trans wrote:

Why did 'should' become the going nomenclature of BDD framworks?
'Should' connotes 'ought', as if something ought to do xyz, but
doesn't necessarily have to. I don't know about you, but I don't write
my tests/specs that way!
'Must' is the word that denotes what our tests/specs do.

I agree. I've suggested the classic requirement-docs' "shall" in the past too, but "must" has an immediacy more appropriate to BDD.

- Charlie

einarmagnus

Stephen Celis wrote:

Perhaps because even we programmers are fallible, and it softens the blow when specs fail. Ah! "my_method" is acting up again!

How about something a bit more threatening...

my_method.better == 42

Perhaps you define an or_else {} along with the spec that cuts off the programmer's little finger?

- Charlie

i'm with you dan - the fact that 'should' somehow produces better code that 'assert' is plain crazy. so is changing a T(DD) to a B.

a @ http://codeforpeople.com/

···

On Nov 18, 2008, at 9:18 AM, Daniel Berger wrote:

Dunno. Don't care. I don't feel the need for DSL-y notation in my
tests.

assert_rocks(Test::Unit) # Test::Unit 2 anyway

Regards,

Dan

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

should makes sense from a 'write the tests first' perspective. still don't like it - but just saying... :wink:

a @ http://codeforpeople.com/

···

On Nov 18, 2008, at 6:30 AM, Charles Oliver Nutter wrote:

I agree. I've suggested the classic requirement-docs' "shall" in the past too, but "must" has an immediacy more appropriate to BDD.

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

Announcing yet another test framework: Musty!

Its perfect for dusting off that old, untested code and bringing it into the modern era! Since its already in production, it MUST be doing the right thing already, right?

-Tobias

···

On Nov 18, 2008, at 8:46 AM, Einar Magnús Boson wrote:

But you are setting up an expectation, right?

my_method.must.do_the_right_thing.
it didn't? but it must!

my_method.should.do_the_right_thing.
it didn't, but it should!

For me the second example feels more natural in a environment where you expect tests to fail at first, maybe this is different in BDD than in TDD, I don't know enough about BDD. Especially when you use tests to design interfaces the "should" thinking comes more natural: You don't have a feature yet but you write down what it should do, then you implement it.

well.daggum do
  my_cotton_pickin_variable.oughta == 13
end

···

On Tue, Nov 18, 2008 at 10:57:28PM +0900, Charles Oliver Nutter wrote:

How about something a bit more threatening...

my_method.better == 42

Thanks for the coffee all over my desk via my nose!

Im_gonna_make_you_an_offer_you_cant_refuse do
   my_method.better know_when_to_shut_up
or_else
   sleep_with_the_fishes
end

def sleep_with_the_fishes
   puts "Why do you hurt me?"
end

- Josh

···

On Nov 18, 2008, at 8:57 AM, Charles Oliver Nutter wrote:

Stephen Celis wrote:

Perhaps because even we programmers are fallible, and it softens the blow when specs fail. Ah! "my_method" is acting up again!

How about something a bit more threatening...

my_method.better == 42

Perhaps you define an or_else {} along with the spec that cuts off the programmer's little finger?

- Charlie

I think Shoulda can create a printable, formatable spec from the tests
themselves that PM's can easily read. Or is that RSpec? Or do either
of them have that feature? I thought one of them did.

That's about the only practical advantage I can see. And, I think
that's something that could be integrated into Test::Unit if we really
wanted it.

Regards,

Dan

···

On Nov 18, 10:25 am, "ara.t.howard" <ara.t.how...@gmail.com> wrote:

On Nov 18, 2008, at 9:18 AM, Daniel Berger wrote:

> Dunno. Don't care. I don't feel the need for DSL-y notation in my
> tests.

> assert_rocks(Test::Unit) # Test::Unit 2 anyway

> Regards,

> Dan

i'm with you dan - the fact that 'should' somehow produces better code
that 'assert' is plain crazy. so is changing a T(DD) to a B.

But you are setting up an expectation, right?

my_method.must.do_the_right_thing.
it didn't? but it must!

my_method.should.do_the_right_thing.
it didn't, but it should!

For me the second example feels more natural in a environment where you
expect tests to fail at first, maybe this is different in BDD than in TDD, I
don't know enough about BDD. Especially when you use tests to design
interfaces the "should" thinking comes more natural: You don't have a
feature yet but you write down what it should do, then you implement it.

This is definitely part of the motivation behind "should."

Keep in mind that BDD started off as an attempt to help TDD newbies to
understand TDD as a design/documentation practice. The word "should"
was chosen for a few reasons.

First, it was to get people who were writing test names like test_pop
to write test names like
test_pop_should_return_the_object_at_the_top_of_the_stack instead.
From this perspective, any such word (should, must, aughta, etc) would
do just fine.

The other motivation for should was in part what Einar suggests here.

If you're writing the test first, then the code doesn't do what it
should yet. So should makes sense in that moment (before the test
passes) to say "should."

Later, when a previously passing test fails, when it says "should'
then you get to ask "should it?" That failure *might* be because a
code change introduced a bug, or it could be that a new requirement
nullifies or somehow challenges a previous requirement.

FWIW,
David

···

On Tue, Nov 18, 2008 at 7:46 AM, Einar Magnús Boson <einarmagnus@tistron.se> wrote:

On 18.11.2008, at 13:30 , Charles Oliver Nutter wrote:

Trans wrote:

Why did 'should' become the going nomenclature of BDD framworks?
'Should' connotes 'ought', as if something ought to do xyz, but
doesn't necessarily have to. I don't know about you, but I don't write
my tests/specs that way!
'Must' is the word that denotes what our tests/specs do.

I agree. I've suggested the classic requirement-docs' "shall" in the past
too, but "must" has an immediacy more appropriate to BDD.

- Charlie

einarmagnus

Paul Brannan wrote:

well.daggum do
  my_cotton_pickin_variable.oughta == 13
end

Maybe we could get really fuzzy with it...

my_method.might == 3

I've been on a few projects where that would be a valid spec.

- Charlie

I think Shoulda can create a printable, formatable spec from the tests
themselves that PM's can easily read. Or is that RSpec? Or do either
of them have that feature? I thought one of them did.

you mean as opposed to reading the *actual* spec right? (aka the code) :wink:

sorry - couldn't resist.

That's about the only practical advantage I can see. And, I think
that's something that could be integrated into Test::Unit if we really
wanted it.

indeedy. and change T to B while you're at it. much more efficient and speedy.

a @ http://codeforpeople.com/

···

On Nov 18, 2008, at 4:12 PM, Daniel Berger wrote:
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

That thar last spec went n' failed with
my_cotton_pickin_variable.oughta == 13but the son of a gun came back with 3

···

On Wed, Nov 19, 2008 at 1:53 AM, Paul Brannan <pbrannan@atdesk.com> wrote:

well.daggum do
my_cotton_pickin_variable.oughta == 13
end

--

Rails, RSpec and Life blog....

Thanks. This thread has been even more fruitful than I expected. I
truly understand why "should" has been used. Not to say "must" and
others are wrong, of course, but I see how the perspective of
anticipation of code-to-be lends to the use of word "should". It
occurs to me that "expect" is also a good word form this perspective;
and interestingly we see that term being used in both TDD and BDD.

Something else I noticed. Originally I wanted reuse the word "assert"
--I like the word. So instead of 'should' I defined a helper to do:

  e.assert == r

Now, with this new perspective, I figure I'd go ahead and use #should.
When I went to convert it however it didn't quite come out as I
expected, because I had put the expectation first and the actualized
result last. Ie.

  expected.should == result

While this is OK, it doesn't quite translate. It reads much better:

  result.should == expected

That's how we talk about these things.

But then it hits me, trying to make this read well has led to a
potential issue. In Ruby equality is tested by the receiver. If we
make result the receiver then it is the one deciding if it is equal to
the expected. But a robust implementation would have the expected
decide.

I realize this is small minutia to the overall issues involved, but I
thought it was an interesting point nonetheless. It would seem, the
way in which we speak and think about things cannot necessarily be
reflected in the way we write our code.

T.

···

On Nov 19, 3:08 pm, "David Chelimsky" <dchelim...@gmail.com> wrote:

This is definitely part of the motivation behind "should."

Keep in mind that BDD started off as an attempt to help TDD newbies to
understand TDD as a design/documentation practice. The word "should"
was chosen for a few reasons.

First, it was to get people who were writing test names like test_pop
to write test names like
test_pop_should_return_the_object_at_the_top_of_the_stack instead.
From this perspective, any such word (should, must, aughta, etc) would
do just fine.

The other motivation for should was in part what Einar suggests here.

If you're writing the test first, then the code doesn't do what it
should yet. So should makes sense in that moment (before the test
passes) to say "should."

Later, when a previously passing test fails, when it says "should'
then you get to ask "should it?" That failure *might* be because a
code change introduced a bug, or it could be that a new requirement
nullifies or somehow challenges a previous requirement.

ara.t.howard wrote:

I think Shoulda can create a printable, formatable spec from the tests
themselves that PM's can easily read. Or is that RSpec? Or do either
of them have that feature? I thought one of them did.

you mean as opposed to reading the *actual* spec right? (aka the code) :wink:

Who are these PM's who can read code? :wink:

sorry - couldn't resist.

No problem. :wink:

Hm, random idea here...if specs were formalized somehow...then we could autogenerate a test spec from the written spec and vice-versa. A bridge between PM's and programmers. Something like UML, but for tests...

I dunno...just a thought. Maybe it already exists?

That's about the only practical advantage I can see. And, I think
that's something that could be integrated into Test::Unit if we really
wanted it.

indeedy. and change T to B while you're at it. much more efficient and speedy.

:stuck_out_tongue:

Speaking of efficiency and speed I highly recommend people upgrade to Test::Unit 2.x. The startup and shutdown methods alone are worth it, as they could save many, many calls that you would otherwise shove in a setup method.

Regards,

Dan

···

On Nov 18, 2008, at 4:12 PM, Daniel Berger wrote:

It's called FIT[1], or, in the Ruby world, Cucumber[2] (successor to
the RSpec Story Runner).

[1] http://fit.c2.com/
[2] GitHub: Let’s build from here · GitHub

···

On Tue, Nov 18, 2008 at 9:21 PM, Daniel Berger <djberg96@gmail.com> wrote:

Hm, random idea here...if specs were formalized somehow...then we could
autogenerate a test spec from the written spec and vice-versa. A bridge
between PM's and programmers. Something like UML, but for tests...

I dunno...just a thought. Maybe it already exists?

--
Avdi