SlideShare a Scribd company logo
IV­Review :: Test Case

       Rails generate a framework for unit and functional tests. You can get pretty good test 
coverage by filling in the framework with tests for the functionality you write. There are two 
important points to test in a Rails application:
    • Testing the Models.
    • Testing the Controllers.

Testing Models:
        When you generate a model with the generate script, Rails also generates a unit test script for 
the model in the test directory. It also creates a fixture, a yaml file containing test data to be loaded 
into the testapp_test database.


Unit Test:
        A test of individual programs or modules in order to ensure that there are no analysis or 
programming errors is known as unit testing. As in other languages, Ruby provides a framework in 
its standard library for setting up, organizing and running tests called Test::Unit. An unit testing 
provides three basic functionalities:

           •   A way to define basic pass/fail tests.
           •   A say to gather like tests together and run them as a group
           •   Tools for running single tests or whole groups of tests.

Code for Unit Testing:

    require 'test_helper' 
    class ApplicantTest < ActiveSupport::TestCase 
      testsome_undefined_variable 
      assert true  "should not save without email_id" do 
      applicant = Applicant.new 
      assert !applicant.save 
      some_undefined_variable 
      assert true 
      end 
   end

In terminal
Unit Testing Case Summary:

    Test case id        Description        Expected Results       Actual Results            Status
1                   Enter the email_id     It should raise      It is not accepting Pass
                    as Blank               error
2                   Enter email_id with  It should accept to  It is not accept       Fail
                    varchar(20)          proceed              more then 20
3                   Enter email_id with  It should accept to  It is not accepting  Pass
                    special characters   proceed
4                   Enter a email_id       It should accept to  It is not accepting  Fail
                    with numerical         proceed


Testing Controllers:
        Controller testing is also known as functional testing. Functional testing tests the following 
type of functionalities of the controllers:
     •   Is the response redirected as expected ? 
     •   Is the expected template rendered? 
     •   Is the routing as expected 
     •   Does the response contain the expected tags? 


Functional Test:
         Functional testing is a type of Black box testing that bases its test cases on the specifications 
of the software component under test. Functions are tested by feeding them input and examining the 
output, and internal program structure is rarely considered.

Code for Functional Testing:

  require 'test_helper' 
  class MailersControllerTest < ActionController::TestCase 
  setup do 
    @user = users(:one) 
  end 

  test "should get index" do 
    get :index 
    assert_response :success 
    assert_not_nil assigns(:users) 
  end 

  test "should get new" do 
    get :new 
    assert_response :success 
  end 
  test "should create user" do 
    assert_difference('User.count') do 
      post :create, :user => @user.attributes 
    end 

    assert_redirected_to user_path(assigns(:user)) 
  end 

  test "should show user" do 
    get :show, :id => @user.to_param 
    assert_response :success 
  end 

  test "should get edit" do 
    get :edit, :id => @applicant.to_param 
    assert_response :success 
  end 

  test "should update applicant" do 
    put :update, :id => @user.to_param, :user => @user.attributes 
    assert_redirected_to user_path(assigns(:user)) 
  end 
 
 test "should destroy user" do 
    assert_difference('User.count', ­1) do 
      delete :destroy, :id => @user.to_param 
    end 
    assert_redirected_to users_path 
  end 
 end

In Terminal:
Functional Testing Case Summary:

    Test case id         Description       Expected Results       Actual Results             Status
1                    Get index             It should get index  It is accepting/   Pass
                                           page/ if is not get display page error 
2                    Get new               It should diplay     It is accepting       Pass
                                           create page
3                    Get new/submit        It should create     Its accepting/not     Pass/Fail
                                           record/not create    accepting
4                    Get show              It should display    Its accepting         Pass
                                           created record
5                    Get destroy           I should delete      Its accepting         Pass
                                           selected record




Using Rake for testing:
      We can use rake utility to test our applications by Various kind of testing strategy. Here are 
few important commands.
    • $rake test ­ Test all unit tests and functional tests (and integration tests, if they exist).
    • $rake test:functionals ­ Run all functional tests.
    • $rake test:units ­ Run all unit tests.
    • $rake test:integration ­ Run all integration tests.
    • $rake test:plugins ­ Run all test in ./vendor/plugins/**/test.
    • $rake test:recent ­ Run tests for models and controllers that have been modified in the last 
      10 minutes:


Some Rake Utility:
    • $rake db:test:clone ­ Recreate the test database from the current environment's database 
      schema.
    • $rake db:test:clone_structure ­ Recreate the test databases from the development structure.
    • $rake db:test:prepare ­ Prepare the test database and load the schema.
    • $rake db:test:purge ­ Empty the test database.

More Related Content

ODP
Query Management system-Iv review
ODP
Query Management system-Ist Review presentation
PPTX
12.registration form
PPT
12 functional-system-testing
PPT
Mohammed Kharma-A flexible framework for quality assurance and testing of sof...
PPTX
Test cases for effective testing - part 1
PPTX
System testing
PPT
Less01 1 introduction_module
Query Management system-Iv review
Query Management system-Ist Review presentation
12.registration form
12 functional-system-testing
Mohammed Kharma-A flexible framework for quality assurance and testing of sof...
Test cases for effective testing - part 1
System testing
Less01 1 introduction_module

What's hot (20)

PPT
QTP&UFT Automation Framework
PPT
Testing strategies
PPSX
Software testing and_quality_assurance_powerpoint_presentation
PPTX
Test design techniques
PPTX
Software Evaluation
PDF
Sqa, test scenarios and test cases
PPTX
Keyword-driven Test Automation Framework
PPT
Automation framework
PPTX
14.web forms server controls
PPT
Data validation option
PPTX
Fundamentals of Software Engineering
PDF
Testing check list
PPTX
UFT Automation Framework Introduction
PPTX
Test cases
PPT
Fundamentals of Software Engineering
PPTX
Fundamentals of Software Engineering
PPTX
RIA 05 - Unit Testing by Ajinkya Prabhune
PPT
Basic Database Testing
ODP
Defects in software testing
PPTX
Software Testing Strategies
QTP&UFT Automation Framework
Testing strategies
Software testing and_quality_assurance_powerpoint_presentation
Test design techniques
Software Evaluation
Sqa, test scenarios and test cases
Keyword-driven Test Automation Framework
Automation framework
14.web forms server controls
Data validation option
Fundamentals of Software Engineering
Testing check list
UFT Automation Framework Introduction
Test cases
Fundamentals of Software Engineering
Fundamentals of Software Engineering
RIA 05 - Unit Testing by Ajinkya Prabhune
Basic Database Testing
Defects in software testing
Software Testing Strategies
Ad

Similar to Query Management system-Iv review (20)

PDF
Testing Legacy Rails Apps
PPTX
TDD & BDD
KEY
Test Coverage in Rails
PDF
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
KEY
How To Test Everything
PDF
How to build quality software
PPTX
12 Introduction to Rails
PPTX
Web tech: lecture 5
PDF
Rails Tips and Best Practices
PDF
What NOT to test in your project
PDF
Owasp tds
PPT
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
KEY
wwc start-launched
PDF
Building Large Web Applications That Are Easy to Maintain
PPT
Test Drive Development in Ruby On Rails
PPT
Acceptance Testing With Selenium
DOC
Resume
PDF
Software Quality and Test Strategies for Ruby and Rails Applications
PDF
Rails vs Web2py
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Testing Legacy Rails Apps
TDD & BDD
Test Coverage in Rails
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
How To Test Everything
How to build quality software
12 Introduction to Rails
Web tech: lecture 5
Rails Tips and Best Practices
What NOT to test in your project
Owasp tds
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
wwc start-launched
Building Large Web Applications That Are Easy to Maintain
Test Drive Development in Ruby On Rails
Acceptance Testing With Selenium
Resume
Software Quality and Test Strategies for Ruby and Rails Applications
Rails vs Web2py
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ad

More from logeshprabu (7)

ODP
Kanchi LUG history
ODP
Query Management System- overview
ODP
Query Management system-IIIrd Review
PDF
Logesh resume
ODP
Query Management system-IInd Review
PDF
Query Management system-Ist review
PPT
Cloud comptuting
Kanchi LUG history
Query Management System- overview
Query Management system-IIIrd Review
Logesh resume
Query Management system-IInd Review
Query Management system-Ist review
Cloud comptuting

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Basic Mud Logging Guide for educational purpose
PDF
01-Introduction-to-Information-Management.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Business Ethics Teaching Materials for college
PDF
Pre independence Education in Inndia.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Cell Structure & Organelles in detailed.
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Basic Mud Logging Guide for educational purpose
01-Introduction-to-Information-Management.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
Anesthesia in Laparoscopic Surgery in India
Microbial disease of the cardiovascular and lymphatic systems
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
human mycosis Human fungal infections are called human mycosis..pptx
Business Ethics Teaching Materials for college
Pre independence Education in Inndia.pdf
PPH.pptx obstetrics and gynecology in nursing
Week 4 Term 3 Study Techniques revisited.pptx

Query Management system-Iv review

  • 1. IV­Review :: Test Case Rails generate a framework for unit and functional tests. You can get pretty good test  coverage by filling in the framework with tests for the functionality you write. There are two  important points to test in a Rails application: • Testing the Models. • Testing the Controllers. Testing Models: When you generate a model with the generate script, Rails also generates a unit test script for  the model in the test directory. It also creates a fixture, a yaml file containing test data to be loaded  into the testapp_test database. Unit Test: A test of individual programs or modules in order to ensure that there are no analysis or  programming errors is known as unit testing. As in other languages, Ruby provides a framework in  its standard library for setting up, organizing and running tests called Test::Unit. An unit testing  provides three basic functionalities: • A way to define basic pass/fail tests. • A say to gather like tests together and run them as a group • Tools for running single tests or whole groups of tests. Code for Unit Testing:     require 'test_helper'      class ApplicantTest < ActiveSupport::TestCase        testsome_undefined_variable        assert true  "should not save without email_id" do        applicant = Applicant.new        assert !applicant.save        some_undefined_variable        assert true        end     end In terminal
  • 2. Unit Testing Case Summary: Test case id Description Expected Results Actual Results Status 1 Enter the email_id  It should raise  It is not accepting Pass as Blank error 2 Enter email_id with  It should accept to  It is not accept  Fail varchar(20) proceed more then 20 3 Enter email_id with  It should accept to  It is not accepting  Pass special characters proceed 4 Enter a email_id  It should accept to  It is not accepting  Fail with numerical proceed Testing Controllers: Controller testing is also known as functional testing. Functional testing tests the following  type of functionalities of the controllers: • Is the response redirected as expected ?  • Is the expected template rendered?  • Is the routing as expected  • Does the response contain the expected tags?  Functional Test:  Functional testing is a type of Black box testing that bases its test cases on the specifications  of the software component under test. Functions are tested by feeding them input and examining the  output, and internal program structure is rarely considered. Code for Functional Testing:   require 'test_helper'    class MailersControllerTest < ActionController::TestCase    setup do      @user = users(:one)    end    test "should get index" do      get :index      assert_response :success      assert_not_nil assigns(:users)    end    test "should get new" do      get :new      assert_response :success    end 
  • 3.   test "should create user" do      assert_difference('User.count') do        post :create, :user => @user.attributes      end      assert_redirected_to user_path(assigns(:user))    end    test "should show user" do      get :show, :id => @user.to_param      assert_response :success    end    test "should get edit" do      get :edit, :id => @applicant.to_param      assert_response :success    end    test "should update applicant" do      put :update, :id => @user.to_param, :user => @user.attributes      assert_redirected_to user_path(assigns(:user))    end     test "should destroy user" do      assert_difference('User.count', ­1) do        delete :destroy, :id => @user.to_param      end      assert_redirected_to users_path    end   end In Terminal:
  • 4. Functional Testing Case Summary: Test case id Description Expected Results Actual Results Status 1 Get index It should get index  It is accepting/ Pass page/ if is not get display page error  2 Get new It should diplay  It is accepting Pass create page 3 Get new/submit It should create  Its accepting/not  Pass/Fail record/not create accepting 4 Get show It should display  Its accepting Pass created record 5 Get destroy I should delete  Its accepting Pass selected record Using Rake for testing: We can use rake utility to test our applications by Various kind of testing strategy. Here are  few important commands. • $rake test ­ Test all unit tests and functional tests (and integration tests, if they exist). • $rake test:functionals ­ Run all functional tests. • $rake test:units ­ Run all unit tests. • $rake test:integration ­ Run all integration tests. • $rake test:plugins ­ Run all test in ./vendor/plugins/**/test. • $rake test:recent ­ Run tests for models and controllers that have been modified in the last  10 minutes: Some Rake Utility: • $rake db:test:clone ­ Recreate the test database from the current environment's database  schema. • $rake db:test:clone_structure ­ Recreate the test databases from the development structure. • $rake db:test:prepare ­ Prepare the test database and load the schema. • $rake db:test:purge ­ Empty the test database.