Importance of writing Test cases in an existing Rails Application

Hey guys!!

In my first article, I going to introduce you the importance of writing test cases(either with Rspec or minitest) with existing Rails Application and why one should write it?

Once you have created your Rails application and now you are quite excited with your bunch of code, files and directories. The only thing that you are missing now is Test cases??

Actually It’s not TDD(Test Driven Development) but It’s the way to learn TDD.

There are three important benefits by writing test cases:

1. You practice about thinking all cases and all possible conditions.
After writing enough tests, you will become aware of where is the possibility of breaking of methods, And as soon as you start TDD you can use this skill  to write robust tests to handle all possible cases of your application.

2. You get habituated with well structured tests.
Once you have done enough practice for writing tests, now you can apply different design patterns for structuring those tests.

3. You find the tests which are hard to  test.
As soon as you get more familiar, you will understand that which part of application is very hard to test and which part of the application is very easy to test. This will provide you the strength of analysis for future estimation of any project.

4. Tests are also very important while migration.
If your rails application has been written all possible test scenarios, then you can upgrade your rails application easily. You can upgrade it to any latest stable version.

Ease into TDD

Whenever you are testing your application,instead of clicking around in the browser to reproduce it, it better two write some cases.

Here is the flow of writing test cases:
a. Write a failing test
b. Run the test,
c. Fix the bug
d. Run the tests
e. Refactor tests

TDD is always preferable to write new rails application.(if you have enough time)

In my next post I will show you how to write tests? and how to pass them.

Have A Happy Coding!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s