RSpec. Testing with RSpec Test::Unit “does the job”, but it would be nice if tests would be more descriptive, more Enlgish-like RSpec uses some Ruby magic.

Slides:



Advertisements
Similar presentations
Python Objects and Classes
Advertisements

1 Conditional Statement. 2 Conditional Statements Allow different sets of instructions to be executed depending on truth or falsity of a logical condition.
CS&E 1111 ExIFs IFs and Nested IFs in Excel Objectives: Using the If function in spreadsheets Nesting If functions.
GoogleTest Primer. Outline Basic Concepts Assertions Basic Assertions Binary Comparison String Comparison Floating-Point Comparison Simple Tests Test.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Example 2.
Guide To UNIX Using Linux Third Edition
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
Unit Testing Using PyUnit Monther Suboh Yazan Hamam Saddam Al-Mahasneh Miran Ahmad
4.1 JavaScript Introduction
Classes, Objects, and Methods
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
Chapter 3 Single-Table Queries
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
SAX Parsing Presented by Clifford Lemoine CSC 436 Compiler Design.
Chapter 2 - Algorithms and Design
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Lecture 5 Selection Control Structures Selection Control Structures Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Chapter 8: Inner Classes. You're an OO programmer, so you know that for reuse and flexibility/extensibility you need to keep your classes specialized.
CIS 234: Control Structures - Selection Dr. Ralph D. Westfall April, 2010.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
1.  Writing snippets of code that try to use methods (functions) from your program.  Each snippet should test one (and only one) function......by calling.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Agenda Getting Started: Using Unix Unix Structure / Features Elements of the Unix Philosophy Unix Command Structure Command Line Editing Online Unix Command.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 21, 2005 Lecture Number: 10.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Selection Statements Selection Switch Conditional.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
Python Functions.
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Asking the USER for values to use in a software 1 Input.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CPS120 Introduction to Computer Science Iteration (Looping)
Asking the USER for values to use in a software 1 Input.
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
The If Block. IF The “if” block can be found in the control tab. The if block means, “IF this happens, THEN do this.” You can put blocks ON the if block.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Exception-Handling Fundamentals  A Java exception is an object that describes an exceptional (that is, error) condition that has occurred in a piece of.
Documenting a function. Documenting a function definition We have a template for information that we need you to put at the top of each function - if.
XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Passing Parameters. 2 home back first prev next last What Will I Learn? List the types of parameter modes Create a procedure that passes parameters Identify.
©2009 HP Confidential1 Proposal to OASIS KMIP TC Stan Feather and Indra Fitzgerald Hewlett-Packard Co. 26 October, 2010 Encoding Options for Key Wrap of.
BIF713 Introduction to Linux. Agenda Getting Started: Using Linux Unix and Linux - Structure / Features Elements of the Linux Philosophy Linux Command.
12. MODULES Rocky K. C. Chang November 6, 2015 (Based on from Charles Dierbach. Introduction to Computer Science Using Python and William F. Punch and.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
STRUCTURED PROGRAMMING Selection Statements. Content 2  Control structures  Types of selection statements  if single-selection statement  if..else.
PRACTICAL COMMON LISP Peter Seibel 1.
 2004 SDU 1 Algorithm Informally speaking, an algorithm is a collection of simple instructions for carrying out a task. Example:  Elementary arithmetic.
IBM Express Runtime Quick Start Workshop © 2007 IBM Corporation Deploying a Solution.
LECTURE # 7 : STRUCTURED PROGRAMMING Selection Statements Tr.Hadeel.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Part VI: Mapping URLs.
similar concepts, different syntax
PL/pgSQL
Selenium HP Web Test Tool Training
Topics Introduction to File Input and Output
Classes, Objects, and Methods
Selection Statements.
Rocky K. C. Chang 15 November 2018 (Based on Dierbach)
Peter Seibel Practical Common Lisp Peter Seibel
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Topics Introduction to File Input and Output
Presentation transcript:

RSpec

Testing with RSpec Test::Unit “does the job”, but it would be nice if tests would be more descriptive, more Enlgish-like RSpec uses some Ruby magic to provide a simple DSL syntax for writing specs/examples (tests) The writing of the tests is more intuitive as well as the output from running the tests 2

Installing Rspec Create a spec directory and place your “specs” there 3

describe() Set of related tests (a.k.a. example group) Takes either a String or Class as argument Describe blocks can be nested All specs must be inside a describe block Automagically creates a class where all the action happens (unlike Test::Unit which always subclasses TestCase class) 4

before() and after() methods before() and after() methods are similar to setup() and teardown() in Test::Unit Can pass in either :each or :all (infrequently used) to specify whether the block will run before/after each test or once before/after all tests before :all could be useful, if for example you only want to connect to DB once 5

it() method Used to define the actual RSpec specifications/examples Takes an optional string that describes the behavior being tested specify() method is an alias of it() Usually, specify() is used for one-line tests and it() is used otherwise; but it really depends on what reads better for a particular test and its output 6

Pending tests If you are not ready to implement certain behavior, but would like to put a test (not to forget to test it in the future) – you can put it in and just omit the actual test block Or you can call pending() method inside the block and RSpec will mark the method as pending 7

calculator.rb 8

calculator_spec.rb 9

Default and documentation formats 10