SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
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.

Contenu connexe

Tendances

QTP&UFT Automation Framework
QTP&UFT Automation FrameworkQTP&UFT Automation Framework
QTP&UFT Automation FrameworkYu Tao Zhang
 
Software testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationSoftware testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationvigneshasromio
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test casesConfiz
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkMikhail Subach
 
Automation framework
Automation framework Automation framework
Automation framework ITeLearn
 
14.web forms server controls
14.web forms server controls14.web forms server controls
14.web forms server controlsPramod Rathore
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering Madhar Khan Pathan
 
Testing check list
Testing check listTesting check list
Testing check listAtul Pant
 
UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework IntroductionHimal Bandara
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering Madhar Khan Pathan
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering Madhar Khan Pathan
 
RIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya PrabhuneRIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya PrabhuneJohannes Hoppe
 
Basic Database Testing
Basic Database TestingBasic Database Testing
Basic Database TestingKumar S
 
Defects in software testing
Defects in software testingDefects in software testing
Defects in software testingsandeepsingh2808
 
Software Testing Strategies
Software Testing StrategiesSoftware Testing Strategies
Software Testing StrategiesAlpana Bhaskar
 

Tendances (20)

QTP&UFT Automation Framework
QTP&UFT Automation FrameworkQTP&UFT Automation Framework
QTP&UFT Automation Framework
 
Testing strategies
Testing strategiesTesting strategies
Testing strategies
 
Software testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationSoftware testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentation
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation Framework
 
Automation framework
Automation framework Automation framework
Automation framework
 
14.web forms server controls
14.web forms server controls14.web forms server controls
14.web forms server controls
 
Data validation option
Data validation optionData validation option
Data validation option
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
Testing check list
Testing check listTesting check list
Testing check list
 
UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework Introduction
 
Test cases
Test casesTest cases
Test cases
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
RIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya PrabhuneRIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya Prabhune
 
Basic Database Testing
Basic Database TestingBasic Database Testing
Basic Database Testing
 
Defects in software testing
Defects in software testingDefects in software testing
Defects in software testing
 
Software Testing Strategies
Software Testing StrategiesSoftware Testing Strategies
Software Testing Strategies
 

Similaire à Query Management system-Iv review

Rails Testing
Rails TestingRails Testing
Rails Testingmikeblake
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choicetoddbr
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails AppsRabble .
 
Unit testing in Force.com platform
Unit testing in Force.com platformUnit testing in Force.com platform
Unit testing in Force.com platformChamil Madusanka
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMSJustinHolt20
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraAndolasoft Inc
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2Andrey Oleynik
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1Albert Rosa
 
www.tutorialsbook.com presents Manual testing
www.tutorialsbook.com presents Manual testingwww.tutorialsbook.com presents Manual testing
www.tutorialsbook.com presents Manual testingTutorials Book
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven developmentStephen Fuqua
 
Testing the Untestable
Testing the UntestableTesting the Untestable
Testing the UntestableMark Baker
 

Similaire à Query Management system-Iv review (20)

Rails Testing
Rails TestingRails Testing
Rails Testing
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
Presentation
PresentationPresentation
Presentation
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
 
Unit testing in Force.com platform
Unit testing in Force.com platformUnit testing in Force.com platform
Unit testing in Force.com platform
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMS
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
 
Testing Guide
Testing GuideTesting Guide
Testing Guide
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
 
www.tutorialsbook.com presents Manual testing
www.tutorialsbook.com presents Manual testingwww.tutorialsbook.com presents Manual testing
www.tutorialsbook.com presents Manual testing
 
Testing methodology
Testing methodologyTesting methodology
Testing methodology
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Testing the Untestable
Testing the UntestableTesting the Untestable
Testing the Untestable
 

Plus de logeshprabu

Kanchi LUG history
Kanchi LUG historyKanchi LUG history
Kanchi LUG historylogeshprabu
 
Query Management System- overview
Query Management System- overviewQuery Management System- overview
Query Management System- overviewlogeshprabu
 
Query Management system-IIIrd Review
Query Management system-IIIrd ReviewQuery Management system-IIIrd Review
Query Management system-IIIrd Reviewlogeshprabu
 
Query Management system-IInd Review
Query Management system-IInd ReviewQuery Management system-IInd Review
Query Management system-IInd Reviewlogeshprabu
 
Query Management system-Ist review
Query Management system-Ist reviewQuery Management system-Ist review
Query Management system-Ist reviewlogeshprabu
 
Cloud comptuting
Cloud comptutingCloud comptuting
Cloud comptutinglogeshprabu
 

Plus de logeshprabu (7)

Kanchi LUG history
Kanchi LUG historyKanchi LUG history
Kanchi LUG history
 
Query Management System- overview
Query Management System- overviewQuery Management System- overview
Query Management System- overview
 
Query Management system-IIIrd Review
Query Management system-IIIrd ReviewQuery Management system-IIIrd Review
Query Management system-IIIrd Review
 
Logesh resume
Logesh resumeLogesh resume
Logesh resume
 
Query Management system-IInd Review
Query Management system-IInd ReviewQuery Management system-IInd Review
Query Management system-IInd Review
 
Query Management system-Ist review
Query Management system-Ist reviewQuery Management system-Ist review
Query Management system-Ist review
 
Cloud comptuting
Cloud comptutingCloud comptuting
Cloud comptuting
 

Dernier

How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational PhilosophyShuvankar Madhu
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 

Dernier (20)

How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational Philosophy
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 

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.