RoR: Tests for beginners

I need a preface to all of my rail posts: I am new.

Do I need to write tests for my application to work correctly or strictly to find breaks?

+4
source share
5 answers

Testing your application is not necessary for it to work, but it is highly recommended and very good practice. Testing your application will help you develop better software and a much more reliable application. In the world of Rails, BDD (Behavior Driven Development) is very used as a testing and development method.

I recommend you two different test suites:

  • The first rspec to help you with all your controllers and model unit testing
  • Cucumber is a test kit that will test your application as a whole (integration test), this is great for a more "real life".

I recommend you check out Rspec and Cucumbers , there are other great test kits like the Test Unit .

Remember that testing your application will give you great benefits!

NOTE. Rspec and Cucumber are not mutually exclusive; in fact, they are recommended to be used together

+4
source

Written tests are not needed in the sense that your application will not work without them, but they are not only designed to fix errors. If you're new, writing tests should also help you understand how things work.

There is no reason not to write tests. Just write good tests and don’t waste time testing things that don’t need to be tested (for example, generated attr_accessor s).

+2
source

This is not necessary at all, but it is considered by almost every ruby ​​developer, who I know as a standard procedure.

I did a couple of rail applications without testing, but as soon as I needed some real ruby ​​backend logic, testing helped me understand what I was doing.

0
source

No, your application does not need to write tests. This is good practice, so if you are not used to writing tests, I would recommend that you start learning. It's easy, and it will save you a lot of headaches on any platform that you use.

0
source

To listen to everyone else, I suggest you find an article on BDD and test the first development. And then they read mockery and knock. Wrapping your head around why and how it is likely to convince you that it is worth the time and effort.

When I first dived into the world of XP and RoR, in which I live, now I was discouraged by what seemed to me like a test mania, but it really pays off at the peak.

The first time someone asked me to write a test first, THEN write the code we tested, I was blown up. But I never returned to my former evil ways.

0
source

All Articles