On Jul 16, 10:04 am, David Chelimsky <
dchelim...@gmail.com> wrote:
> Hi James,
>
> This sounds like you're using Cucumber for more detail than is common.
> Not saying it's wrong or right, but AFAIK in most cases folks don't
> specify models, for example, with Cucumber, they do that with more
> granular tools like RSpec, test/unit, shoulda, etc, and use Cucumber
> for a higher level view of things (when I visit xxx view or screen,
> etc).
>
> Are you also using a more object-focused tool like RSpec, or are you
> using Cucumber exclusively?
On Jul 16, 6:20 pm, Matt Wynne <
m...@mattwynne.net> wrote:
>
> Yeah that sounds pretty different to any set-up I've heard of James!
>
Please bear in mind that I do not come from a OO programming
background; that for me, all of this, Ruby, Rails, OOP, ORM, RDBMS,
TTD, BDD, etc. was, until recently, simply words in a book, or a bunch
of books. I still work with a 4GL and several CODASYL DBMS every day.
This is to say that I have developed my own approach to the
organisation problems presented by BDD. While this seems to suffice
for my needs it may not scale well for use by large groups.
I have used RSpec in the past. I repeatedly attempted to make it work
for me, but somehow I could never get my head around what it was
doing. I tried to understand RSpec stories when they were first
introduced, could it actually be 2 years ago? Again, my want of
relevant background prevented me from understanding what evidently so
many others could see plainly. Then I ran into Cucumber, and the
mystery was revealed to me.
Perhaps it was just a coincidence, because beginning last November I
was at last sufficiently recovered to really put some serious effort
into our conversion project, but I think not. Cucumber's total
bifurcation between user request and developer implementation really
clarified things for me. It was then I could begin the painful
process of mastering both a new language and a new approach.
Those who are longtime members of the RSpec list may recall my first
attempts. My excruciatingly detailed "features" that were not features
at all, but a rather poor attempt at pseudo code. Gradually however,
with more than a few nudges from those with a deal more experience
than I, I acquired more and more knowledge and a few skills. I
believe that I have the gist of things now and that I have moved from
the consciously incompetent to the (cautiously) consciously competent
stage.
One of the things that I read in my early attempts to understand TDD
said, in effect, do not test code that you did not write. Now, at the
time this struck me as both rather obvious and rather obscure, since I
lacked the knowledge to know for certain that I really understood what
was written. After initially dealing with excessive detail in
cucumber I gradually came to a similar position; that basically, if it
is not manifested as a user consumable then it probably does not need
to be tested.
Now, I know that this is not true in an absolute sense. There are all
sorts of systems where the invisible workings are absolutely vital and
the visible result negligible. But, my environment is a commercial
system. Which, when reduced to its essentials, is nothing more than a
bunch of filing cabinets related to each other though a series of
lists, each of which is traversed in a more or less repetitive or
predicable manner. Sometimes one totals what is on a list, sometimes
one inserts something into a filing cabinet and records the fact on a
list, and sometimes one discards a file and removes it from a list.
The central facet of this is that that these lists are always driven
by and exposed to the user. The point is, in a commercial system,
there is precious little that is not presented as a user consumable at
some point.
So, to answer your question, I am testing with Cucumber exclusively at
the moment, save only those parts I had done previously in RSpec. So
far this decision, or rather development for I never consciously made
such a decision, seems to work well. Since I have relatively high
powered equipment to develop with, hitting the local postgresql
database for testing has not yet had a significant impact on run
times. No doubt this will change but for now it seems more economical
to just run against the dbms than to spend the effort to build mock
objects.
In any case, I retain some scepticism about the efficacy of mocking
dbms rows. Yesterday for instance, I encountered a strange situation
where a particular row, that should be returned by my class method
given the data it contained, was not returned and so my feature was
failing. After a long session with Cucumber, adding more detailed
steps (but not very many, just two in fact) I was able to trace the
problem back to snippet of SQL code that had its arguments
interpolated. The proximate cause of the bug was actually in
PostgreSQL v8.2 and was the result of an implicit cast of the
arguments by the dbms itself. If I had tested against a mock instead
of the dbms this bug, in all probability, would have lain silent for
years in the application code. Because if I wrote a mock then that
mock would give me what I expected the dbms to give me, which proved
rather different in the actual case.
As for specifying models in Cucumber, I do not, at least not in the
sense of laying out all of the columns and their default attributes.
However, I do drive the UI through Cucumber and there are few columns
that are not exercised by the UI. I also have a few class methods on
some models and this I also drive through Cucumber, as detailed
above. As I am approaching this development one user feature at a
time, and as so far each primitive feature seems to localise naturally
around one principal model, I find that the layout of features/app/
models keeps things nicely segregated for me. I can then do things
like cucumber -r features features/app/models/currency and get all of
the features relating principally to the currency model and avoid the
overhead of running all the rest. One can achieve the same thing with
file name conventions but I just find my approach maps more naturally
to the Rails conventions and therefore I can more readily find things
when I have a problem with a particular model or controller.
I find that I have written more than I should have, so I will stop. I
crave your indulgence.