Testing and application

Hi
I have a rails application with no tests.
I decided early not to use a TDD or to have any automatic tests as I
am the only develope, as I tested it manually and as I thought many of
the proposed test procedures could be substituted by just looking at
the code.
However I was wrong. When the code became complex enough and when
refactoring becomes important automatic testing seems necessery.

Most guidelines, tutorials and discussions about testings concerns
application that is to be implemented, while I have an application
that is already running.

How to proceed, with a large application,manually tested, that one
would like to add automatic tests to. ?

What framwork should I use to add tests (I can not apply TDD to a
already implemented application) – rails test framework?, rspec?,
shoulda? or some other ?
Rspec seems to have a simpler syntax and focus on a higher level of
testings.

What should be tested first?

Should I test features that I alredy have tested manually?

Any other advices ?

Would appreciate any help

I’d start with cucumber and capybara to verify key stories. That way you
at least have smoke tests for going through the system. If you have time
after that, put in some lower level rspec tests - mainly around areas of
complexity.

Then every time you add a feature, change a piece of code or get a bug,
add a test. That way you’ll end up with good code coverage in the areas
of the app that need it (the parts with complexity, bugs or which you
touch a lot) for the smallest practical investment of time.

You’ll want to use factory girl or something similar for creating stuff
like user objects for your tests. The rspec book is good, but big. Rails
testing prescriptions isn’t bad. There are also lots of blog postings,
so I’d just get started and then google when you run into something.

Best Wishes,
Peter

I totally agree with Peter, you should implement cucumber tests at
first, and then if you’ll still have some time, you should implement
RSpec tests also.
The Rspec book isn’t so big, I read it twice completely and 3 time
more some single chapters, it’s really a great book, don’t miss the
chapters which aren’t technical, they contain a lot answers on concept
questions what to test and how,.

I met the same problem, as you, Hans ~ 3-4 months ago. I was trying to
find some patterns of testing already written applications, but didn’t
find anything.
So I started from noting on the paper which user scenarios do I have
in my app, and then implemented ~ 60% scenarios coverage by cucumber
for all good and bad cases.
It took really a lot of time ~ 0.3 - 0.5 of app implementing time,
especially a lot of time at first takes implementing of basic cucumber
steps, but later when you already have a good base, the work goes much-
much faster.

So My Advice is:

  1. "The RSpec book (it covers Cucumber also)
  2. Implement Cucumber tests
  3. Implement RSpec tests
  4. Continue app implementing in BDD manner.

P.S. You can check also for Gerard Maszaros “xUnit Test Patterns”
book, this one is really big, and it’s really difficult to read it
completely, but it contains also a lot of answers on concept question,
like what is mock, stub, double in testing theory, when you should
each one of these and a lot of other things.

thanks for all good advices
I will follow them and start by getting the Rspec book and will then
use cucumber and finally rspec for any new or refactored code

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs