Writing good test suites?

Hello,

Before I started using rails, I never really was one to write unit
tests or any types of test suites really. The more I’ve been using
rails the more I started to write bigger and more comprehensive test
suites (since it is so easy to do it with the rails framework). I
pretty much picked up all my test writing habits as I wrote my tests
this past year. I never looked into any tips, advice, or instruction
on how to write good test suites.

So, I was wondering if anybody could offer any insight, pointers,
links to resources, or anything really that could help me refine my
approach to writing better test suites. How do you look at your
software when you try are writing your test suites (it seems like it
is a bit hard to do so objectively), how do you get good coverage,
what kind of things do you always want to test in a web application,
how do you share the load between unit tests and functional tests (for
example, the unit tests for a Person model would have extensive
validation coverage, but I’m guessing the functional test wouldn’t
need quite the same level of depth).

In short, how do I know if I am writing good tests for my code?

Thanks,
-carl

Check out
http://bparanj.blogspot.com/2006/11/resources-for-testing-ruby-on-rails.html

Read the tests in technoweenie’s code (
http://svn.techno-weenie.net/projects/ ). I had no idea what I was
doing or
what the big deal was until I started reading his code and looking at
his
tests. Then it was like that instant when you finally figure out what
the
weird little inexplicable thingy on your Swiss army knife is used for,
and
just for a minute you feel like you’re MacGuyver.

  • foobario

In short, how do I know if I am writing good tests for my code?

When you don’t have any bugs in your code, you know that you are
writing good tests.

On 2-Nov-06, at 10:20 AM, [email protected] wrote:

In short, how do I know if I am writing good tests for my code?

When you don’t have any bugs in your code, you know that you are
writing good tests.

you might consider rcov - provides C0 test coverage analysis.

“Code coverage shouldn’t be abused (in few words, C0 coverage
guarantees nothing) but it’s still useful for testing: it will at
least tell you when your tests need more work, and most importantly
where.” [1]

[1]http://eigenclass.org/hiki.rb?rcov

J

Pragmmatic Unit Testing is an excellent book on this topic. Check it
out.

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