FitNesse.NET tips and tricks Gojko Adzic

Slides:



Advertisements
Similar presentations
Effective Test Driven Database Development Gojko Adzic twitter.com/gojkoadzic.
Advertisements

SLIM and the future of FitNesse Gojko Adzic
 What is FitNesse / Slim? (10’)  Setting up FitNesse – demo (10’)  Introduction to Snacks-R-Us (10’)  Iteration 1 (35’)  Iteration 2 (35’)  Integration.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
CS 177 Recitation Week 8 – Methods. Questions? Announcements  Project 3 milestone due next Thursday 10/22 9pm  Turn in with: turnin –c cs177=xxxx –p.
Data Structures Topic #3. Today’s Agenda Ordered List ADTs –What are they –Discuss two different interpretations of an “ordered list” –Are manipulated.
Guide To UNIX Using Linux Third Edition
CS 11 C++ track: lecture 8 Today: Inheritance. Inheritance (1) In C++ we create classes and instantiate objects An object of class Fruit "is-a" Fruit.
Agile Acceptance Testing Closing the communication gap in software projects Gojko Adzic
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
OOP Languages: Java vs C++
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
Programming Languages and Paradigms Object-Oriented Programming.
Table-Driven Acceptance Testing Mario Aquino Principal Software Engineer Object Computing, Inc.
Agile Acceptance Testing Software development by example Gojko Adzic
Dynamic Data Exchanges with the Java Flow Processor Presenter: Scott Bowers Date: April 25, 2007.
Java: Chapter 1 Computer Systems Computer Programming II.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
PHP meets MySQL.
FitNesse On the Road to Success By Pierre Veragen
The Java Programming Language
CS533 Concepts of Operating Systems Jonathan Walpole.
Cognos Finance Tips & Techniques Part I Aimee Sousa Cognos.
Effective Test Driven Database Development Gojko Adzic
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
Effective Test Driven Database Development Gojko Adzic
Modern Software Development Using C#.NET Chapter 5: More Advanced Class Construction.
Copyright  Hannu Laine C++-programming Part 1 Hannu Laine.
Agenda Object Oriented Programming Reading: Chapter 14.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Classes and Multiform Projects.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
Frameworks CompSci 230 S Software Construction.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
Copyright by Gregory W. Hislop 1 INFO 324 Team Process and Product Week 2 Dr. Jennifer Booker College of Information Science and.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Processes and Virtual Memory
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
© 2012 LogiGear Corporation. All Rights Reserved FitNesseFitNesse Authors: Nghia Pham 1.
Michel Grootjans Pascal Mestdach.  Michel Grootjans ◦ Enterprise Architect ◦
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
CHAPTER 5 Introduction to Word Processing. OBJECTIVES 1.Define common terms related to word processing 2.Create, format, edit, save, and print Microsoft.
XP Tutorial 3 New Perspectives on JavaScript, Comprehensive1 Working with Arrays, Loops, and Conditional Statements Creating a Monthly Calendar.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
CSE Operating System Principles Protection.
Introduction to Exceptions in Java CS201, SW Development Methods.
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
Introduction to Compiler Construction
Chapter 14: System Protection
FIT Testing 2 December 7, 2004.
Java Programming Language
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
JavaScript Charting Library
Functions, Part 1 of 3 Topics Using Predefined Functions
Programming Fundamentals Lecture #3 Overview of Computer Programming
Smart Integration Express
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Functions, Part 1 of 3 Topics Using Predefined Functions
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Functions, Part 1 of 3 Topics Using Predefined Functions
Presentation transcript:

FitNesse.NET tips and tricks Gojko Adzic

FitNesse.NET allows you to save lots of time by writing fixture code efficiently and by not writing fixture code when you don’t really need it.

Simple Sample Domain

Example: define + list links Define Links NameUrl Googlehttp:// Yahoohttp:// List Links NameUrl Googlehttp:// Yahoohttp://

Automatic collection wrapping Instead of creating your own row/array fixtures, use a flow fixture and just return an array out from a method - it gets mapped to array fixture Works in do/sequence flow mode Works on IEnumerable

Automatic collection wrapping public class FlowCollections: DoFixture { private ILinkRepository repo = new MemoryLinkRepository(); public Fixture DefineLinks() { return new LinkSetupFixture(repo); } public IEnumerable ListLinks() { return repo.FindAll(); }

System under test If the call does not map to anything in the fixture, flow fixtures check a “system under test” Set the system under test and map domain service/repository/factory calls directly to tables Perhaps best on Sequence fixtures

System under test public class FlowSystemUnderTest : DoFixture { private ILinkRepository repo = new MemoryLinkRepository(); public FlowSystemUnderTest() { SetSystemUnderTest(repo); } public Fixture DefineLinks() { return new LinkSetupFixture(repo); }

System under test info.fitnesse.FlowSystemUnderTest Define Links NameUrl Googlehttp:// Yahoohttp:// Find All NameUrl Googlehttp:// Yahoohttp://

With keyword Set the system under test from the test page |with|method call| |with|new|class name| |with|new|class name|constr arg1|arg2|…| Use this to switch between systems under test dynamically

With Keyword info.fitnesse.WithSystemUnderTest withnewinfo.fitnesse.MemoryLinkRepository Define Links NameUrl Googlehttp:// Yahoohttp:// Find All NameUrl Googlehttp:// Yahoohttp://

With Keyword public class WithSystemUnderTest : DoFixture { public Fixture DefineLinks() { return new LinkSetupFixture((ILinkRepository) this.mySystemUnderTest); }

Naming SUTs |name|foo|with|… with phrase| |name|bar|with|… with phrase| |use|foo| … |use|bar|

Naming SUTs namegooglewithnewLinkGooglehttp:// nameyahoowithnewLinkYahoohttp:// usegoogle checkvalidtrue useyahoo checkvalidtrue

System under test in other fixtures From recently, you can use system under test for other fixtures as well! Eg for a column fixture as a much more flexible target object! Allows you to define only test-specific methods in fixtures!

Column fixture SUT public class LinkValidityCheck:fit.ColumnFixture { public LinkValidityCheck() { SetSystemUnderTest(new Link()); } public String comment; }

Column fixture SUT Link validity check nameurlvalid?comment googlehttp:// set, correct blankhttp:// not set googleblankfalseurl not set googlewww.google.comfalseurl not in correct format

Alternating system under test Switch SUT in runtime to load up other objects Use Reset() to clean up before new row This is a very efficient way to implement a subset fixture for huge data sets

Alternating SUT Define Links NameUrlId? Googlehttp:// Yahoohttp:// Microsofthttp:// Check Links IdName?Url? <<googleGooglehttp://

Alternating SUT public class LinkCheckFixture : ColumnFixture { private ILinkRepository repo; public LinkCheckFixture(ILinkRepository repo) { this.repo = repo; } public int Id { set { SetSystemUnderTest(repo.FindById(value));} }

Automatic domain object wrapping Don’t use a fixture – use your domain class in the table header FitNesse.NET automatically creates a DoFixture and sets the system under test to a new instance of your class

Cell Handlers Tell FitNesse how to interpret a set of cells –Match by cell content –Match by object type Extend AbstractCellHandler Load by using Cell Handler Loader loadSavedFixtureHandlerFitLibrary loadSavedFixtureHandlerFit

Example: Regex public class RegExHandler: AbstractCellHandler { public override bool Match(string searchString, System.Type type) { return searchString.StartsWith("/") && searchString.EndsWith("/") && typeof(string).Equals(type); } public override bool HandleEvaluate(Fixture fixture, Parse cell, Accessor accessor) { object actualValue=accessor.Get(fixture); if (actualValue == null) return false; Regex expected =new Regex(cell.Text.Substring(1,cell.Text.Length-2)); return expected.IsMatch(actualValue.ToString()); }

Regex to the rescue Named SUTs can’t be used as parameters –This isn’t possible: –|name|google|with|new|…| –|save|google| But that would be really cool! So let’s implement it using a cell handler!

Saved fixture handler public class SavedFixtureHandler:AbstractCellHandler { public override bool Match(string searchString, System.Type type) { return searchString.StartsWith("\"") && searchString.EndsWith("\""); } public override void HandleInput(Fixture fixture, Parse cell, Accessor accessor) { String innerText=cell.Text.Substring(1, cell.Text.Length-2); accessor.Set(fixture, ((FlowFixtureBase) fixture).NamedFixture(innerText)); }

We can now use it like this! namegooglewithnewLinkGooglehttp:// nameyahoowithnewLinkYahoohttp:// save"google" save"yahoo" find all nameurl Googlehttp:// Yahoohttp:// info.fitnesse.MemoryLinkRepository

Suite config files Extract all technical information into a file Keep test pages nice and tidy, easily readable Set up with !define COMMAND_PATTERN=%m –c mySuite.config %p See all options on

Suite config files D:\work\netfit2\fixtures\fixtures\bin\debug\fixtures.dll info.fitnesse info.fitnesse.SavedFixtureHandler info.fitnesse.SavedFixtureHandler

Now we can do this! Memory Link Repository namegooglewithnewLinkGooglehttp:// nameyahoowithnewLinkYahoohttp:// save"google" save"yahoo" find all nameurl Googlehttp:// Yahoohttp://

We can write tests with no fixture code! But “can” is not the same as “should”!

FitNesse Pages tell us “what” Fixtures tell us “how”

Bridging the Communication Gap learn how to improve communication between business people and software implementation teams find out how to build a shared and consistent understanding of the domain in your team learn how to apply agile acceptance testing to produce software genuinely fit for purpose discover how agile acceptance testing affects your work whether you are a programmer, business analyst or a tester learn how to build in quality into software projects from the start, rather than control it later

Upcoming events Games in the cloud: March 5 th Next.NET event: March 23rd Web Tech Exchange: May 11-15

Where next?