(Advanced) Web Application Development Test Driven Development with Ruby and Rails Bruce Scharlau, University of Aberdeen, 2013.

Slides:



Advertisements
Similar presentations
Applied Ruby on Rails & AJAX An insight into the technology and principles behind a social networking community.
Advertisements

Instant JChem - current status and what's coming soon. Tim Dudgeon Solutions for Cheminformatics.
Dealing with the chaos monkey
Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
Making working software as a team
Group Projects Making working software as a team Bruce Scharlau, University of Aberdeen, 2011.
Welcome to Jestek Web Site SITE DELUX Making Web Site Changes: Site Add-Ons This tutorial is designed to help you make changes on your own with your SiteDelux.
1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development.
Acceptance Testing vs. Unit Testing: A Developers Perspective Owen Rogers Rob Styles
SharePoint Forms All you ever wanted to know about forms but were afraid to ask.
NoodleTools Create a [bibliography, source list…] * [Your name/title/contact info]* *For the brackets, fill in your specific information.
Microsoft ® Office Word 2007 Training Table of Contents III: Use fields to create a TOC and create multiple TOCs Neeginan Institute of Applied Technology.
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Acceptance Testing.
An open source QA stack testing tools for agile teams Presented by Aaron Evans
Web Application Development and Advanced Web App Development CS1019/CS2012 Introduction Bruce Scharlau, University of Aberdeen, 2012.
MYOB to QuickBooks Conversions Presented by Alex Wild.
Software Testing with Visual Studio 2013 & Team Foundation Server 2013 Benjamin Day.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
Calendar Browser is a groupware used for booking all kinds of resources within an organization. Calendar Browser is installed on a file server and in a.
APC Issue Tracking Introduction and Tour of APC’s JIRA Issue Tracker.
27-Jun-15 Rails. What is Rails? Rails is a framework for building web applications This involves: Getting information from the user (client), using HTML.
Agile Testing with Testing Anywhere The road to automation need not be long.
Guide to Using Message Maker Robert Snelick National Institute of Standards & Technology (NIST) December 2005
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Background The Encyclopedio of Life (EOL) is an ROR open source project to create a free, online reference source and database for every one of the 1.8.
Advanced Excel for Finance Professionals A self study material from South Asian Management Technologies Foundation.
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
UNIT TESTING FOR SQL Prepared for SUGSA CodeLabs Alain King Paul Johnson.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Unit and Functional Testing Your Flex Applications Mike Nimer Dir. Of Engineering nomee.com.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Testing Especially Unit Testing. V-model Wikipedia:
Version control Using Git Version control, using Git1.
1 OPOL Training (OrderPro Online) Prepared by Christina Van Metre Independent Educational Consultant CTO, Business Development Team © Training Version.
Lecture 11 Rails Topics SaaSSaaS Readings: SaaS book Ch February CSCE 740 Software Engineering.
Ruby on Rails CSE 190M, Spring 2009 Week 6. Overview How to use a database Demo creating a blog application on Rails Explain how the application works.
Oracle Data Integrator Procedures, Advanced Workflows.
Software Construction Lecture 18 Software Testing.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
1 Legacy Code From Feathers, Ch 2 Steve Chenoweth, RHIT Right – Your basic Legacy, from Subaru, starting at $ 20,295, 24 city, 32 highway.
© Hive Studios 2011 Ivan Pavlović, Hive Studios Visual C# MVP, MCT, CSM
Ruby on Rails By S. Christopher Hellriegel. Overview 1. What is Ruby on Rails? 2. What is MVC? 3. Simple example 4. Wow, that was cool!
Testing, Testing & Testing - By M.D.ACHARYA QA doesn't make software but makes it better.
Connecting with Computer Science2 Objectives Learn how software engineering is used to create applications Learn some of the different software engineering.
1 Presentation Title Test-driven development (TDD) Overview David Wu.
Mohit Anand, Software Engineer Adobe 1 Selecting GUI Automation Testing Tool for Mobile Domain.
Peter Batchelor & Liddy Nevile - OZeWAI HiSoftware Accessibility Solutions Peter Batchelor & Liddy Nevile
HOW AND WHY TO LOVE CUCUMBER By Dana Scheider. Is This Your Programming Experience?
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
We Behatin’. INTRODUCTION Behat background 3 Behat prep Getting started
Testing Unit Testing In Evergreen Kevin Beswick Laurentian University / Project Conifer.
Your current Moodle 1.9 Minimum Requirements Ability to do a TEST RUN! Upgrading Moodle to Version 2 By Ramzan Jabbar Doncaster College for the Deaf By.
Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence.
Version control, using Git
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
NoodleTools Create a [bibliography, source list…] *
MVC Framework, in general.
Bruce Scharlau, University of Aberdeen, 2017
Johanna Rothman Create Technical Excellence Chapter 9
(Advanced) Web Application Development
TDD adoption plan 11/20/2018.
Test-driven development (TDD)
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Open Source Tool Based Automation solution with Continuous Integration and end to end BDD Implementation Arun Krishnan - Automation Manager Maria Afzal-
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
NoodleTools Create a [bibliography, source list…] *
Presentation transcript:

(Advanced) Web Application Development Test Driven Development with Ruby and Rails Bruce Scharlau, University of Aberdeen, 2013

Why do we bother testing? Bruce Scharlau, University of Aberdeen, 2013

When should we do testing?

A simple testing game Bruce Scharlau, University of Aberdeen, 2013 Game details at Three one minute rounds Done in pairs: pick a developer & a tester You might need to move seats

Outline for this lecture Testing application options with Rails built- in tools Unit testing rails Controller testing rails Bruce Scharlau, University of Aberdeen, Use basic guide on testing with methods, etc

Testing is part of the agile approach Ensures the code does what client requests Can be changed in line with client needs Can be automated instead of manual Bruce Scharlau, University of Aberdeen, 2013

You must test your app If you don’t test your app, then you don’t know a) Either when you break it with new features b) Or which specific part broke Bruce Scharlau, University of Aberdeen, 2013 Tests will tell you this information If you don’t make the time now, then you’ll make the time after your app breaks. And it will break… You choose when to do tests

Agile provides better feedback Bruce Scharlau, University of Aberdeen,

Shortening feedback loop saves money Finding problems sooner, means they are fixed sooner Fixed sooner costs less money Fixed sooner means less time spent on them Fixed sooner means more time for other things, such as deploying app, and bringing in revenue Bruce Scharlau, University of Aberdeen, 2013

Follow the TDD principles Bruce Scharlau, University of Aberdeen,

Use red, green, refactor to code Bruce Scharlau, University of Aberdeen, Write a little test 3. Get test to pass 2. Stub out code. Watch test fail 4. Refactor Cycle time < 10 minutes Make it green, then make it clean

Tests based on customer’s business needs Only write tests for what’s needed in app This includes acceptance tests co-written by customer – avoids misinterpretation Bruce Scharlau, University of Aberdeen, 2013 only code what’s needed, then stop, move to next feature

Marick’s matrix of testing Bruce Scharlau, University of Aberdeen, 2013 Image from Bsed on ideas from

There is no one tool for testing Need to use a variety of tests Unit test logical unit (class, method, etc) in isolation Integration test for components Functional tests for end-to-end System tests using same interface as users System integration for collaborating apps Performance tests to ensure throughput Bruce Scharlau, University of Aberdeen, 2013

Ruby provides various approaches to testing Cucumber and RSpec confirms methods conform to expected behaviour of code Test::Unit confirms methods work as expected Bruce Scharlau, University of Aberdeen, 2013

a)create cookbook: rails new cookbook then cd into cookbook and bundle install b) setup migrations with rake db:create c) setup recipe model rails generate scaffold recipe title:string description:string date:date instructions:text d)rake db:migrate to push migration to db server e) rails server to start server (don’t need to really though) f) rake test:units to setup test db open test/unit/recipe_test.rb to write tests and run g) open fixtures file and edit for data h) open functional test andfix :one for :hot or :cold and run with rake test:functionals i) test view in functional: assert_select 'h1', "Listing recipes” j) run rake:tests to do all again as group We’ll use the cookbook for testing

Rails creates tests for us Bruce Scharlau, University of Aberdeen, 2013 We just need to fill in code to use them Tests automatically created

We have a variety of tests available Bruce Scharlau, University of Aberdeen, 2013 We just need to fill in code to use them Tests for models Tests for controllers

We first check the test framework Bruce Scharlau, University of Aberdeen, 2013 Create test database if doesn’t exist Test database defined in database.yml ruby test/unit/recipe_test.rb

Need to prepare system with rake Bruce Scharlau, University of Aberdeen, 2013 Run ‘rake test:units’ to copy schema to test db and run tests Only works if you’ve used migrations, otherwise need to save table structure and load that into test db

We can use simple unit test code Bruce Scharlau, University of Aberdeen, 2013 Default test, delete Could also do validation checks Might need to change ‘require’ line ActiveSupport::TestCase and Testing for details and examples test “recipe test” do

Add more tests for other models Bruce Scharlau, University of Aberdeen, 2013 As add models to app, you write tests Keep checking the methods work Can run tests independent of server, so speeds up working application

Use fixtures to load test data Bruce Scharlau, University of Aberdeen, 2013 Provides continuity of tests Can have one for each scenario One place for data instead of being in test file

Fixture code in test is cleaner Bruce Scharlau, University of Aberdeen, 2013 Reference fixture names and values Load fixture file – must be same as table name Can use fixture repeatedly in multiple tests recipe.save will put it into db

Bruce Scharlau, University of Aberdeen, 2013 We can also test the controllers Need to change ‘require’ line when run without rake Change default of :one to :hot from fixture file Run as is to check setup Run with ‘rake test:functionals’

Test the controller outside server Bruce Scharlau, University of Aberdeen, 2013 Change default of :one to :hot from fixture file or you will have error One dot per test with ruby test…

We can write better tests Bruce Scharlau, University of Aberdeen, 2013 Basic controller tests 7 methods of controller Add new tests for methods you add

Test views from within controllers Bruce Scharlau, University of Aberdeen, 2013 Select element, declare value

We can run all tests together Bruce Scharlau, University of Aberdeen, 2013 We can run all tests at once as app grows

We can test the parts of the application as we write them Bruce Scharlau, University of Aberdeen, 2013 We know the code works before we start server We know code will be checked as we write new code Provides a safety net for our coding: mistakes will be caught and fixed sooner

Combine your testing to cover whole application You can use unit testing with Test::Unit, to test your whole Rails application Details about this in the Agile Web Development book Look at BDD tests in more detail in the next lecture Bruce Scharlau, University of Aberdeen, 2013

There are still some parts missing from the tests We can add integration tests from Rails to mix controllers, etc We can also use Rspec and Cucumber to good effect to test the whole app Cucumber also tests web pages for us too Bruce Scharlau, University of Aberdeen, 2013 We’ll look at Rspec and Cucumber next week

Summary Use unit tests for the models Use functional tests for the controllers Use ‘rake test’ to run all tests Bruce Scharlau, University of Aberdeen, 2013 Tests provide a safety net for our coding Testing is a big part of the Ruby community