SlideShare a Scribd company logo
Test Driven  Development  By  Uma Mahesh Varma
Test Drive Development  Introduction Importance of T.T.D Rails webs application directory structure  Explanation about test folder in rails directory structure  Unit Tests Functional Tests
What is meant by test drive development ?  The answer for the above question is as fallows, TTD (Test Drive Development) is an part of software development techniques based on writing some small test cases before implementing code or new functionalities.   Test drive development is nothing but developing a product by writing unit tests that define the code requirement. These tests returns true or false. Running these tests rapidly brings you a correct behavior of the developer to develop an application. 
Procedure of T.D.D Write a test.   Run the test and check whether it fails or not.  If not Write some code.  Run the automated test. Refactor.
Rails webs application directory structure my_app/ README Installation and usage information Rakefile Build script app/ Model, View, and Controller files go here components/ Reusable components config/ Configuration and database connection parameters db/ Schema and migration information doc/ Autogenerated documentation lib/ Shared code log/ Logfiles produced by your application public/ Web-accessible directory. Your application runs from here script/ Utility scripts test/ Unit, functional, and integration tests, fixtures, and mocks tmp/ Runtime temporary files vendor/ Imported code
Test directory  Fixtures  Integration Functional Unit test_helper.rb
Unit Test require File.dirname(__FILE__) + '/../test_helper‘ class UserTest < Test::Unit::TestCase fixtures :users def test_truth assert true end end
Unit Test >> ruby test/unit/test_user.rb Loaded suite test/unit/user_test Started EE Finished in 0.559942 seconds. 1) Error: test_truth(UserTest): MysqlError: Unknown database ‘myapp_test' 1 tests, 0 assertions, 0 failures, 2 errors
Unit Test A Database Just for Tests Myapp> mysqladmin -u root create myapp_test Myapp> ruby test/unit/myapp_test.rb Loaded suite test/unit/myapp_test Started E Finished in 0.06429 seconds. 1) Error: test_truth(ProductTest): ActiveRecord::StatementInvalid: MysqlError: Table ‘myapp_test. users' doesn't exist: DELETE FROM users 1 tests, 0 assertions, 0 failures, 1 errors
Unit Test  myapp > rake db:test:prepare Myapp > ruby test/unit/user_test.rb Loaded suite test/unit/user_test Started . Finished in 0.085795 seconds. 1 tests, 1 assertions, 0 failures, 0 errors
Unit Test A Real Unit Test validates_presence_of :name, :email, :mobilenum validates_numericality_of : mobilenum validates_uniqueness_of :name validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => &quot;must be a URL for a GIF, JPG, or PNG image&quot;
Unit Test def test_invalid_with_empty_attributes user = User.new assert ! user .valid? assert user .errors.invalid?(:name) assert user .errors.invalid?(:email) assert user .errors.invalid?(:mobileno) assert user.errors.invalid?(:image_url) end
Unit Test  Myapp > ruby test/unit/user_test.rb Loaded suite test/unit/user_test Started .. Finished in 0.092314 seconds. 2 tests, 6 assertions, 0 failures, 0 errors
Unit Test def test_image_url ok = %w{ fred.gif fred.jpg fred.png FRED.JPG FRED.Jpg http://a.b.c/x/y/z/fred.gif } bad = %w{ fred.doc fred.gif/more fred.gif.more } ok.each do |name| user = User.new(:name => “mahesh&quot; , :email => “umamahesh_nyros@yahoo.com&quot; , :mobilenum => 9866439593, :image_url => name) assert user.valid?, usererrors.full_messages end bad.each do |name| user = User.new(:name => “mahesh&quot; , :email => “umamahesh_nyros@yahoo.com&quot; , :mobilenum => 9866439593, :image_url => name) assert user.valid?, usererrors.full_messages  end
Fixtures mahesh: id: 1 name: mahesh email:  [email_address] mobilenum: 9866439593 image_url: maheshprofile.jpg
Unit Test Fixtures :users def test_unique_name user = User.new(:name => user(:mahesh).name, :email => “umamahesh_nyros@yahoo.com&quot; , :mobilenum => 9866439593, :image_url => &quot;fred.gif&quot; ) assert !user.save assert_equal &quot;has already been taken&quot; , user.errors.on(:name) end
Unit test supports  assert(boolean,message) assert_equal(expected, actual,message) assert_not_equal(expected, actual,message) assert_nil(object,message) assert_not_nil(object,message) assert_match(pattern, string,message) assert_no_match(pattern, string,message)
Functional Testing of Controllers require ‘user_helper’ def UserTest < Test::Unit::Testclass def test_index assert true end end
Functional Testing of Controllers myapp > ruby test/functional/user_test_controller.rb Loaded suite test/functional/ user_test_controller.rb Started . Finished in 0.0604571 seconds. 1 tests, 1 assertions, 0 failures, 0 errors
Thank You
Ad

More Related Content

What's hot (20)

UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
2 selenium-aakar gupte
2 selenium-aakar gupte2 selenium-aakar gupte
2 selenium-aakar gupte
aakar gupte
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 
Codeception
CodeceptionCodeception
Codeception
Jonathan Lau
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
Simon Guest
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UI
Ivan Pashko
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Edureka!
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Run Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test ManagerRun Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test Manager
Daniel Herken
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
Seth McLaughlin
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
Anuraj S.L
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
Jim Lane
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver TutorialSelenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
vivek_prahlad
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
 
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and SprayNexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Matthew Farwell
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
Seth McLaughlin
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
2 selenium-aakar gupte
2 selenium-aakar gupte2 selenium-aakar gupte
2 selenium-aakar gupte
aakar gupte
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
Simon Guest
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UI
Ivan Pashko
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Edureka!
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Run Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test ManagerRun Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test Manager
Daniel Herken
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
Seth McLaughlin
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
Anuraj S.L
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
Jim Lane
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver TutorialSelenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
vivek_prahlad
 
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and SprayNexthink Library - replacing a ruby on rails application with Scala and Spray
Nexthink Library - replacing a ruby on rails application with Scala and Spray
Matthew Farwell
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
Seth McLaughlin
 

Similar to Test Drive Development in Ruby On Rails (20)

Rails Testing
Rails TestingRails Testing
Rails Testing
mikeblake
 
Qa process
Qa processQa process
Qa process
Aila Bogasieru
 
Qa process
Qa processQa process
Qa process
Aila Bogasieru
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
RubenGray1
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meter
Purna Chandar
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
Facundo Farias
 
Automation - Apache JMeter
Automation - Apache JMeterAutomation - Apache JMeter
Automation - Apache JMeter
Wira Santos
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
Rabble .
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
Albert Rosa
 
UI Testing
UI TestingUI Testing
UI Testing
Josh Black
 
Php tests tips
Php tests tipsPhp tests tips
Php tests tips
Damian Sromek
 
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
Tricode (part of Dept)
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
michael.labriola
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Ukraine
 
Automation frameworks
Automation frameworksAutomation frameworks
Automation frameworks
Vishwanath KC
 
Testing Presentation
Testing PresentationTesting Presentation
Testing Presentation
sureshpkumar
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
Harshad Mane
 
Rails Testing
Rails TestingRails Testing
Rails Testing
mikeblake
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
RubenGray1
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meter
Purna Chandar
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Automation - Apache JMeter
Automation - Apache JMeterAutomation - Apache JMeter
Automation - Apache JMeter
Wira Santos
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
Rabble .
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
Albert Rosa
 
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
Tricode (part of Dept)
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Ukraine
 
Automation frameworks
Automation frameworksAutomation frameworks
Automation frameworks
Vishwanath KC
 
Testing Presentation
Testing PresentationTesting Presentation
Testing Presentation
sureshpkumar
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
Harshad Mane
 
Ad

More from Nyros Technologies (20)

MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
Web Designing Bugs - Fixes By Nyros Developer
Web Designing Bugs - Fixes By Nyros DeveloperWeb Designing Bugs - Fixes By Nyros Developer
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
Capistrano Deployment By Nyros Developer
Capistrano Deployment By Nyros DeveloperCapistrano Deployment By Nyros Developer
Capistrano Deployment By Nyros Developer
Nyros Technologies
 
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros Developer
Nyros Technologies
 
Web 2.0 Design Standards By Nyros Developer
Web 2.0 Design Standards By Nyros DeveloperWeb 2.0 Design Standards By Nyros Developer
Web 2.0 Design Standards By Nyros Developer
Nyros Technologies
 
Web 2.0 By Nyros Developer
Web 2.0 By Nyros DeveloperWeb 2.0 By Nyros Developer
Web 2.0 By Nyros Developer
Nyros Technologies
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
Nyros Technologies
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros Developer
Nyros Technologies
 
New Features in .Net Framework 4.0 By Nyros Developer
New Features in .Net Framework 4.0 By Nyros DeveloperNew Features in .Net Framework 4.0 By Nyros Developer
New Features in .Net Framework 4.0 By Nyros Developer
Nyros Technologies
 
Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
Nyros Technologies
 
Connect with Facebook to Rails Application By Nyros Developer
Connect with Facebook to Rails Application By Nyros DeveloperConnect with Facebook to Rails Application By Nyros Developer
Connect with Facebook to Rails Application By Nyros Developer
Nyros Technologies
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Research on Audio and Video Streaming
Research on Audio and Video StreamingResearch on Audio and Video Streaming
Research on Audio and Video Streaming
Nyros Technologies
 
User Interface
User InterfaceUser Interface
User Interface
Nyros Technologies
 
Audio and Video Streaming
Audio and Video StreamingAudio and Video Streaming
Audio and Video Streaming
Nyros Technologies
 
Deploying Rails Apps with Capistrano
Deploying Rails Apps with CapistranoDeploying Rails Apps with Capistrano
Deploying Rails Apps with Capistrano
Nyros Technologies
 
Capistrano - Deployment Tool
Capistrano - Deployment ToolCapistrano - Deployment Tool
Capistrano - Deployment Tool
Nyros Technologies
 
Social Networking
Social NetworkingSocial Networking
Social Networking
Nyros Technologies
 
Payment Gateway
Payment GatewayPayment Gateway
Payment Gateway
Nyros Technologies
 
Aws
AwsAws
Aws
Nyros Technologies
 
MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
Web Designing Bugs - Fixes By Nyros Developer
Web Designing Bugs - Fixes By Nyros DeveloperWeb Designing Bugs - Fixes By Nyros Developer
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
Capistrano Deployment By Nyros Developer
Capistrano Deployment By Nyros DeveloperCapistrano Deployment By Nyros Developer
Capistrano Deployment By Nyros Developer
Nyros Technologies
 
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros Developer
Nyros Technologies
 
Web 2.0 Design Standards By Nyros Developer
Web 2.0 Design Standards By Nyros DeveloperWeb 2.0 Design Standards By Nyros Developer
Web 2.0 Design Standards By Nyros Developer
Nyros Technologies
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros Developer
Nyros Technologies
 
New Features in .Net Framework 4.0 By Nyros Developer
New Features in .Net Framework 4.0 By Nyros DeveloperNew Features in .Net Framework 4.0 By Nyros Developer
New Features in .Net Framework 4.0 By Nyros Developer
Nyros Technologies
 
Oops in PHP By Nyros Developer
Oops in PHP By Nyros DeveloperOops in PHP By Nyros Developer
Oops in PHP By Nyros Developer
Nyros Technologies
 
Connect with Facebook to Rails Application By Nyros Developer
Connect with Facebook to Rails Application By Nyros DeveloperConnect with Facebook to Rails Application By Nyros Developer
Connect with Facebook to Rails Application By Nyros Developer
Nyros Technologies
 
Research on Audio and Video Streaming
Research on Audio and Video StreamingResearch on Audio and Video Streaming
Research on Audio and Video Streaming
Nyros Technologies
 
Deploying Rails Apps with Capistrano
Deploying Rails Apps with CapistranoDeploying Rails Apps with Capistrano
Deploying Rails Apps with Capistrano
Nyros Technologies
 
Ad

Recently uploaded (20)

The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 

Test Drive Development in Ruby On Rails

  • 1. Test Driven Development By Uma Mahesh Varma
  • 2. Test Drive Development Introduction Importance of T.T.D Rails webs application directory structure Explanation about test folder in rails directory structure Unit Tests Functional Tests
  • 3. What is meant by test drive development ?  The answer for the above question is as fallows, TTD (Test Drive Development) is an part of software development techniques based on writing some small test cases before implementing code or new functionalities.  Test drive development is nothing but developing a product by writing unit tests that define the code requirement. These tests returns true or false. Running these tests rapidly brings you a correct behavior of the developer to develop an application. 
  • 4. Procedure of T.D.D Write a test.  Run the test and check whether it fails or not. If not Write some code. Run the automated test. Refactor.
  • 5. Rails webs application directory structure my_app/ README Installation and usage information Rakefile Build script app/ Model, View, and Controller files go here components/ Reusable components config/ Configuration and database connection parameters db/ Schema and migration information doc/ Autogenerated documentation lib/ Shared code log/ Logfiles produced by your application public/ Web-accessible directory. Your application runs from here script/ Utility scripts test/ Unit, functional, and integration tests, fixtures, and mocks tmp/ Runtime temporary files vendor/ Imported code
  • 6. Test directory Fixtures Integration Functional Unit test_helper.rb
  • 7. Unit Test require File.dirname(__FILE__) + '/../test_helper‘ class UserTest < Test::Unit::TestCase fixtures :users def test_truth assert true end end
  • 8. Unit Test >> ruby test/unit/test_user.rb Loaded suite test/unit/user_test Started EE Finished in 0.559942 seconds. 1) Error: test_truth(UserTest): MysqlError: Unknown database ‘myapp_test' 1 tests, 0 assertions, 0 failures, 2 errors
  • 9. Unit Test A Database Just for Tests Myapp> mysqladmin -u root create myapp_test Myapp> ruby test/unit/myapp_test.rb Loaded suite test/unit/myapp_test Started E Finished in 0.06429 seconds. 1) Error: test_truth(ProductTest): ActiveRecord::StatementInvalid: MysqlError: Table ‘myapp_test. users' doesn't exist: DELETE FROM users 1 tests, 0 assertions, 0 failures, 1 errors
  • 10. Unit Test myapp > rake db:test:prepare Myapp > ruby test/unit/user_test.rb Loaded suite test/unit/user_test Started . Finished in 0.085795 seconds. 1 tests, 1 assertions, 0 failures, 0 errors
  • 11. Unit Test A Real Unit Test validates_presence_of :name, :email, :mobilenum validates_numericality_of : mobilenum validates_uniqueness_of :name validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => &quot;must be a URL for a GIF, JPG, or PNG image&quot;
  • 12. Unit Test def test_invalid_with_empty_attributes user = User.new assert ! user .valid? assert user .errors.invalid?(:name) assert user .errors.invalid?(:email) assert user .errors.invalid?(:mobileno) assert user.errors.invalid?(:image_url) end
  • 13. Unit Test Myapp > ruby test/unit/user_test.rb Loaded suite test/unit/user_test Started .. Finished in 0.092314 seconds. 2 tests, 6 assertions, 0 failures, 0 errors
  • 14. Unit Test def test_image_url ok = %w{ fred.gif fred.jpg fred.png FRED.JPG FRED.Jpg http://a.b.c/x/y/z/fred.gif } bad = %w{ fred.doc fred.gif/more fred.gif.more } ok.each do |name| user = User.new(:name => “mahesh&quot; , :email => “[email protected]&quot; , :mobilenum => 9866439593, :image_url => name) assert user.valid?, usererrors.full_messages end bad.each do |name| user = User.new(:name => “mahesh&quot; , :email => “[email protected]&quot; , :mobilenum => 9866439593, :image_url => name) assert user.valid?, usererrors.full_messages end
  • 15. Fixtures mahesh: id: 1 name: mahesh email: [email_address] mobilenum: 9866439593 image_url: maheshprofile.jpg
  • 16. Unit Test Fixtures :users def test_unique_name user = User.new(:name => user(:mahesh).name, :email => “[email protected]&quot; , :mobilenum => 9866439593, :image_url => &quot;fred.gif&quot; ) assert !user.save assert_equal &quot;has already been taken&quot; , user.errors.on(:name) end
  • 17. Unit test supports assert(boolean,message) assert_equal(expected, actual,message) assert_not_equal(expected, actual,message) assert_nil(object,message) assert_not_nil(object,message) assert_match(pattern, string,message) assert_no_match(pattern, string,message)
  • 18. Functional Testing of Controllers require ‘user_helper’ def UserTest < Test::Unit::Testclass def test_index assert true end end
  • 19. Functional Testing of Controllers myapp > ruby test/functional/user_test_controller.rb Loaded suite test/functional/ user_test_controller.rb Started . Finished in 0.0604571 seconds. 1 tests, 1 assertions, 0 failures, 0 errors