views:

41

answers:

1

Disclaimer: I have not used RoR, and I have not generated tests. But, I will still dare to post this question.

Quality Assurance is theoretically impossible to get 100% right in general (Undecidable problem ;), and it is hard in practice.

So many developers do not understand that writing good automated tests is an art, and it is hard.

When I hear that RoR generates the tests for you, I get very skeptical. It cannot be that easy.

Testing is a general concept; it applies across languages. So does the concept of code contracts, it is similar for languages that support it. Code contracts do not generate themselves. The programmer must add the requirements and the promises manually, after doing some thinking about the algorithm / function. If a human gets it wrong, then the tools will propagate the error. Similarly with testing - it takes human judgement about what should happen. Tests do not write themselves, and we are far from the day when a business analyst can just have a conversation with a computer and tell it informally what the requirements are and have the computer do all the work.

There is no magic ... how can RoR generate good tests for you?

Please shed some light on this. Opinions are ok, for this is a community wiki. Thanks!

+9  A: 

Where have you read that Rails generates tests? It doesn't. What it generates is a simple default test stub for every model or controller that you create with the command line tool.

Let's say that you create a model for a blog post:

script/generate model post

Rails automatically generates the file:

test/unit/post_test.rb

That has the following content:

require 'test_helper'

class PostTest < ActiveSupport::TestCase
  # Replace this with your real tests.
  def test_truth
    assert true
  end
end

As you can see, the content of the test is still up to you.

Here's more info on Rails testing: http://guides.rubyonrails.org/testing.html

rogeriopvl