Test Driven .NET Development with Fitnesse

Total Page:16

File Type:pdf, Size:1020Kb

Test Driven .NET Development with Fitnesse Test Driven .NET Development with FitNesse second edition Gojko Adzic Test Driven .NET Development with FitNesse: second edition Gojko Adzic Copy-editor: Marjory Bisset Cover picture: Brian Samodra Published 2009 Copyright © 2008-2009 Neuri Limited Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where these designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author has taken care in the preparation of this book, but makes no expressed or implied warranty of any kind and assumes no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Neuri Limited 25 Southampton Buildings London WC2A 1AL United Kingdom You can also contact us by e-mail: [email protected] Register your book online Visit http://gojko.net/fitnesse and register your book online to get free PDF updates and notifications about corrections or future editions of this book. ISBN: 978-0-9556836-2-6 REVISION:2009-12-08 Preface to the second edition ........................................................... vii What's new in this version? ..................................................... vii Training and consultancy ................................................................ ix Acknowledgements ......................................................................... xi About the author ........................................................................... xiii I. Getting started .............................................................................. 1 1. Introduction ......................................................................... 3 Who should read this book? .............................................. 3 Why bother with TDD? .................................................... 4 Beyond unit tests .............................................................. 6 Getting FIT ...................................................................... 7 FitNesse or NUnit? ........................................................... 9 The next step .................................................................. 12 2. Installing FitNesse ............................................................... 15 Setting up FitNesse ......................................................... 16 A quick test .................................................................... 17 How FitNesse connects to .NET classes ............................ 22 Don't forget the test ........................................................ 23 Playtime ......................................................................... 25 II. FitNesse and TDD in practice ..................................................... 27 3. Our Project ......................................................................... 29 Lottery rules ................................................................... 29 Selected user stories ........................................................ 29 Applying TDD to our project .......................................... 30 The next step .................................................................. 39 4. Writing basic tests ............................................................... 41 ColumnFixture — the Swiss Army knife of FitNesse ........ 43 Testing in plain English .................................................. 47 Playtime ......................................................................... 51 5. Writing simple test scripts ................................................... 53 Passing values between tables .......................................... 54 Writing a simple test script ............................................. 56 Use data-transfer objects directly .................................... 59 Using symbols to check dynamic values ........................... 61 Checking for errors ......................................................... 62 Playtime ......................................................................... 64 6. Writing efficient test scripts ................................................ 67 Better test scripts with DoFixture .................................... 69 iii Test Driven .NET Development with FitNesse Use DoFixture keywords for better control ...................... 73 Keep ActionFixture in mind ............................................ 75 Playtime ......................................................................... 76 7. Removing duplication ......................................................... 79 Group related tests into test suites ................................... 79 Include pages and use them as components ..................... 82 Reuse entire suites with symbolic links ............................ 83 Use markup variables to parameterise test pages .............. 84 Defining common actions ............................................... 85 Remove irrelevant information ....................................... 86 Acceptance tests should focus on business rules ............... 88 Hide parts of the page ..................................................... 88 Playtime ......................................................................... 88 8. Coordinating fixtures .......................................................... 91 Embed fixtures for best results ........................................ 92 Use SetUpFixture to prepare the stage for tests ................ 94 Create test suites in flow mode ........................................ 99 Wrapping business objects with DoFixture .................... 101 Playtime ....................................................................... 102 9. Working with collections ................................................... 103 Testing lists of objects ................................................... 104 Checking for empty collections ...................................... 108 Beware of test extensions ............................................... 109 Use RowFixture for better precision .............................. 111 Playtime ....................................................................... 114 III. Advanced FitNesse usage ......................................................... 117 10. Working in a team ........................................................... 119 Options for team setup .................................................. 119 Organising the files ....................................................... 123 Integrating with automated build tools .......................... 127 11. Testing web interfaces ..................................................... 135 Choosing the right thing to test ..................................... 135 Introducing Selenium ................................................... 138 Connecting from FitNesse ............................................. 142 Running tests on a remote server ................................... 147 More Selenium tests ...................................................... 149 12. Testing database code ...................................................... 151 Connecting to the database ........................................... 151 iv Working with stored procedures ................................... 155 Preparing test data ........................................................ 156 Executing statements .................................................... 157 Verifying query results .................................................. 157 Other DbFit features ..................................................... 158 13. Testing legacy code .......................................................... 161 Covering legacy code with tests ..................................... 161 Use blank cells to print out results ................................. 162 Use show and check with FitLibrary ............................... 163 Wrap existing objects for tests ....................................... 163 Use ArrayFixture and RowFixture to capture data batches ......................................................................... 164 Using existing forms for regression tables ...................... 165 14. Using business domain objects directly ............................ 169 System under test with ColumnFixtures ........................ 169 Changing the system under test ..................................... 170 Using collections directly .............................................. 172 Setting the system under test from FitNesse ................... 174 Using named fixtures .................................................... 175 Don't go too far ............................................................ 175 15. Tips and tricks ................................................................. 177 What really happens during a test? ................................ 177 Attaching the Visual Studio debugger ............................ 182 Load non-standard cell operators for simpler comparis- ons ............................................................................... 183 Simplify verifications
Recommended publications
  • 2019 Stateof the Software Supply Chain
    2019 State of the Software Supply Chain The 5th annual report on global open source software development presented by in partnership with supported by Table of Contents Introduction................................................................................. 3 CHAPTER 4: Exemplary Dev Teams .................................26 4.1 The Enterprise Continues to Accelerate ...........................27 Infographic .................................................................................. 4 4.2 Analysis of 12,000 Large Enterprises ................................27 CHAPTER 1: Global Supply of Open Source .................5 4.3 Component Releases Make Up 85% of a Modern Application......................................... 28 1.1 Supply of Open Source is Massive ...........................................6 4.4 Characteristics of Exemplary 1.2 Supply of Open Source is Expanding Rapidly ..................7 Development Teams ................................................................... 29 1.3 Suppliers, Components and Releases ..................................7 4.5 Rewards for Exemplary Development Teams ..............34 CHAPTER 2: Global Demand for Open Source ..........8 CHAPTER 5: The Changing Landscape .......................35 2.1 Accelerating Demand for 5.1 Deming Emphasizes Building Quality In ...........................36 Open Source Libraries .....................................................................9 5.2 Tracing Vulnerable Component Release 2.2 Automated Pipelines and Downloads Across Software Supply Chains
    [Show full text]
  • Acceptance Testing How Cslim and Fitnesse Can Help You Test Your Embedded System
    Acceptance Testing How CSlim and FitNesse Can Help You Test Your Embedded System Doug Bradbury Software Craftsman, 8th Light Tutorial Environment git clone git://github.com/dougbradbury/c_learning.git cd c_learning ./bootstrap.sh or with a live CD: cp -R cslim_agile_package c_clearning cd c_learning git pull ./bootstrap.sh Overview Talk w/ exercises: Acceptance Tests Tutorial: Writing Acceptance tests Tutorial: Fitnesse Tutorial: CSlim Talk: Embedded Systems Integration Bonus Topics Introductions Who are you? Where do you work? What experience do you have with ... embedded systems? acceptance testing? FitNesse and Slim? Objectives As a result of this course you will be able to: Understand the purposes of acceptance testing; Use acceptance tests to define and negotiate scope on embedded systems projects; Integrate a CSlim Server into your embedded systems; Objectives (cont) As a result of this course you will be able to: Add CSlim fixtures to your embedded system; Write Fitnesse tests to drive the execution of CSlim fixtures; Write and maintain suites of tests in a responsible manner. Points on a star How many points does this star have? Star Point Specification Points on a star are counted by the number of exterior points. Points on a star How many points does this star have? By Example 3 5 9 Points on a star Now, how many points does this star have? Robo-draw Pick a partner ... Acceptance Testing Collaboratively producing examples of what a piece of software is supposed to do Unit Tests help you build the code right. Acceptance Tests
    [Show full text]
  • Measuring Test Data Uniformity in Acceptance Tests for the Fitnesse and Gherkin Notations
    Journal of Computer Science Original Research Paper Measuring Test Data Uniformity in Acceptance Tests for the FitNesse and Gherkin Notations Douglas Hiura Longo, Patrícia Vilain and Lucas Pereira da Silva Department of Informatics and Statistics, Federal University of Santa Catarina, Florianópolis, Brazil Article history Abstract: This paper presents two metrics designed to measure the data Received: 23-11-2020 uniformity of acceptance tests in FitNesse and Gherkin notations. The Revised: 24-02-2021 objective is to measure the data uniformity of acceptance tests in order Accepted: 25-02-2021 to identify projects with lots of random and meaningless data. Random data in acceptance tests hinder communication between stakeholders Corresponding Author: Douglas Hiura Longo and increase the volume of glue code. The main contribution of this Department of Informatics and paper is the implementation of the proposed metrics. This paper also Statistics, Federal University of evaluates the uniformity of test data from several FitNesse and Gherkin Santa Catarina, Florianópolis, projects found on GitHub, as a means to verify if the metrics are Brazil applicable. First, the metrics were applied to 18 FitNesse project Email: [email protected] repositories and 18 Gherkin project repositories. The measurements taken from these repositories were used to present cases of irregular and uniform test data. Then, we have compared the notations from FitNesse and Gherkin in terms of projects and features. In terms of projects, no significant difference was observed, that is, FitNesse projects have a level of uniformity similar to Gherkin projects. However, in terms of features and test documents, there was a significant difference.
    [Show full text]
  • Agile Testing Practices
    Agile Testing Practices Megan S. Sumrell Director of Transformation Services Valtech Introductions About us… Now about you… Your name Your company Your role Your experience with Agile or Scrum? Personal Expectations Agenda Introductions Agile Overview Traditional QA Teams Traditional Automation Approaches Role of an Agile Tester Testing Activities Refine Acceptance Criteria TDD Manual / Exploratory Testing Defect Management Documentation Performance Testing Regression Testing Agenda Continued Test Automation on Agile Teams Testing on a Greenfield Project Testing on a Legacy Application Estimation Sessions Sprint Planning Meetings Retrospectives Infrastructure Skills and Titles Closing Agile Overview Agile Manifesto "We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan That is, while there is value in the items on the right, we value the items on the left more." Scrum Terms and Definitions User Story: high level requirements Product Backlog: list of prioritized user stories Sprint : one cycle or iteration (usually 2 or 4 weeks in length) Daily Stand-up: 15 minute meeting every day to review status Scrum Master: owns the Scrum process and removes impediments Product Owner: focused on ROI and owns priorities on the backlog Pigs and Chickens Traditional QA Teams How are you organized? When do you get involved in the project? What does your “test phase” look like? What testing challenges do you have? Traditional Test Automation Automation Challenges Cost of tools Hard to learn Can’t find time Maintenance UI dependent Only a few people can run them Traditional Test Pyramid UNIT TESTS Business Rules GUI TESTS Will these strategies work in an Agile environment? Food for Thought…….
    [Show full text]
  • Architecting TIBCO Streambase Applications Unit 4 Functional Testing
    Architecting TIBCO StreamBase Applications Unit 4 Functional Testing © Copyright 2000-2014 TIBCO Software Inc. StreamBase Functional Testing Overview • Test Methodology and Tooling • Test Development Tasks • Types of Tests • Tool Overview • Functional Test Areas © Copyright 2000-2014 TIBCO Software Inc. 2 StreamBase Test Methodology and Tooling 3 © Copyright 2000-2013 TIBCO Software Inc. Test Methodology and Tooling Partial list taken from Project Methodology Unit: We Can Help. • by validating/ creating recipes for the application of SB specifics to the general rules • by establishing delivery team discipline around particularly important good practices that often fall by the wayside • by promoting systematic use of lifecycle tool support and integrating into customer SDLC practices and infrastructure © Copyright 2000-2014 TIBCO Software Inc. 4 StreamBase Functional Testing: Tasks 5 © Copyright 2000-2013 TIBCO Software Inc. Functional Testing Tasks • Test Development Tasks – Test Plan – Test Case Specification – Test Development – Test Data Generation • Functional Testing Infrastructure and DevOps Setup and Integration • CI Server Integration and SLAs • Regression Suite Initiation and Frequency, Results Review and Notification © Copyright 2000-2014 TIBCO Software Inc. 6 StreamBase Types of Tests 7 © Copyright 2000-2013 TIBCO Software Inc. Types of Application Testing • Functional Requirements Testing • System Integration Testing • Performance Testing and Tuning • Throughput Metrics • Latency Metric • This is a science; see performance unit © Copyright 2000-2014 TIBCO Software Inc. 8 More Types of Testing – Failover/Failback Testing • Application Server Failure • Inbound Messaging Server(s) Failover/Failure • Outbound Messaging Server(s) Failover/Failure • Persistence (RDBMS) Server Failover/Failure • Network Failure • Storage/Cache Failure – Disaster Recovery Testing – Stress Testing/Burn-in © Copyright 2000-2014 TIBCO Software Inc.
    [Show full text]
  • Agile Methods: Testing Challenges, Solutions & Tool Support
    Agile Methods: Testing Challenges, Solutions & Tool Support Attique Ur Rehman Ali Nawaz Muhammad Abbas Department of Computer and Department of Computer and Department of Computer and Software Engineering, CEME, Software Engineering, CEME, Software Engineering, CEME, National University of Sciences and National University of Sciences and National University of Sciences and Technology, Islamabad, Pakistan Technology, Islamabad, Pakistan Technology, Islamabad, Pakistan [email protected] [email protected]. [email protected] e.edu.pk edu.pk ABSTRACT methodology is rapid and we therefore opt this methodology for rapid development of software so taking out time for Agile development is conventional these days and with the comprehensive testing is difficult. Research has shown that agile passage of time software developers are rapidly moving from methodology does not provides you this time for testing. We this Waterfall to Agile development. Agile methods focus on study will identify the major challenges which may arise during delivering executable code quickly by increasing the agile testing and they can relate to the management of testing or responsiveness of software companies while decreasing can relate to the implementation of testing. The challenges can development overhead and consider people as the strongest pillar come at the organizational level between teams or can they can of software development. As agile development overshadows occur for the specific product. We also propose the solution for Waterfall methodologies for software development, it comes up those challenges in light of the tools. with some distinct challenges related to testing of such software. Our study is going to discuss the challenges this approach has In this paper we have done a research about the challenges that stirred up.
    [Show full text]
  • Benchmarking Web-Testing - Selenium Versus Watir and the Choice of Programming Language and Browser
    Benchmarking Web-testing - Selenium versus Watir and the Choice of Programming Language and Browser Miikka Kuutila, M3S, ITEE, University of Oulu, Finland Mika Mäntylä, M3S, ITEE, University of Oulu, Finland Päivi Raulamo-Jurvanen, M3S, ITEE, University of Oulu, Finland Email: [email protected], Postal address: P.O.Box 8000 FI-90014 University of Oulu Abstract Context: Selenium is claimed to be the most popular software test automation tool. Past academic works have mainly neglected testing tools in favour of more methodological topics. Objective: We investigated the performance of web-testing tools, to provide empirical evidence supporting choices in software test tool selection and configuration. Method: We used 4*5 factorial design to study 20 different configurations for testing a web-store. We studied 5 programming language bindings (C#, Java, Python, and Ruby for Selenium, while Watir supports Ruby only) and 4 Google Chrome, Internet Explorer, Mozilla Firefox and Opera. Performance was measured with execution time, memory usage, length of the test scripts and stability of the tests. Results: Considering all measures the best configuration was Selenium with Python language binding for Google Chrome. Selenium with Python bindings was the best option for all browsers. The effect size of the difference between the slowest and fastest configuration was very high (Cohen’s d=41.5, 91% increase in execution time). Overall Internet Explorer was the fastest browser while having the worst results in the stability. Conclusions: We recommend benchmarking tools before adopting them. Weighting of factors, e.g. how much test stability is one willing to sacrifice for faster performance, affects the decision.
    [Show full text]
  • Making Test Automation Work in Agile Projects
    Making Test Automation Work in Agile Projects Agile Testing Days 2010 Lisa Crispin With Material from Janet Gregory 1 Introduction - Me . Programming background . Test automation from mid-90s . Agile from 2000 . Many new automation possibilities! 2 Copyright 2010: Lisa Crispin Introduction - You . Main role on team? . Programming, automation experience? . Using agile approach? . Current level of automation? (Test, CI,deployment, IDEs, SCCS...) 3 Copyright 2010: Lisa Crispin Takeaways Foundation for successful test automation . “Whole Team” approach . When to automate . Apply agile principles, practices . Good test design principles . Identifying, overcoming barriers . Choosing, implementing tools . First steps We won’t do any hands-on automation, but will work through some examples together 4 Copyright 2010: Lisa Crispin Why Automate? . Free up time for most important work . Repeatable . Safety net . Quick feedback . Help drive coding . Tests provide documentation 5 Copyright 2010: Lisa Crispin Barriers to Test Automation What’s holding you back? 6 Copyright 2010: Lisa Crispin Pain and Fear . Programmers don’t feel manual test pain . Testers treated as safety net . Fear . Programmers lack testing skills . Testers lack programming skills 7 Copyright 2010: Lisa Crispin Initial Investment . Hump of pain . Legacy code, changing code . Tools, infrastructure, time Effort Effort Time Copyright 2010: Lisa Crispin It’s Worth It . ROI – explain to management . “Present value” of automated tests . Acknowledge hump of pain 9 Copyright 2010: Lisa Crispin Economics of Test Design . Poor test practices/design = poor ROI . Tests had to understand, maintain . Good test practices/design = good ROI . Simple, well-designed, refactored tests 10 Copyright 2010: Lisa Crispin Exercise – What’s holding YOU back? .
    [Show full text]
  • Anthony Escalona (206) 406-4145; [email protected]; Middle Village, NY, 11379
    Anthony Escalona (206) 406-4145; [email protected]; Middle Village, NY, 11379. Technical Skills: Quality: Test tools development, Git, Jenkins, Travis, CI/CD, Selenium, Specflow, Cucumber, xUnit Languages: Templating, .Net, Bash, Python, Java, Javascript, Ruby, LaTeX Cloud: AWS: CFT, EC2, S3, SWF, EMR, Service Catalog Azure: AzureRM(Compute), AzureAutomation, Webhooks VMWare: Automation Stack, vRA / vRO (vRealize Automation / Orchestration) ServiceNow: CMP Catalog Development Deployment : CloudFormation,CodePipeline, Azure DevOps, Chef, Ansible, 12-factor Data: SSIS, Pentaho (PRD, PDI), Talend Open Studio Experience: City of New York - DOIIT NY, NY Cloud Engineer, reporting to Director of Cloud Services March 2016 – Present • Designed and Implemented continuous delivery pipelines using Azure (AZ) DevOps • Developed solution for Cloud Deployment Pipeline and Release Definition supporting approval gates and notifications • Plan and develop strategies for departments CI/CD build systems • Designed and Developed Azure Resource Manager (ARM) templates for all Notify NYC resources with supported unit tests to provision, deploy, and operate web and function services • Developed and Integrated components with Identity Management (IAM) roles, IAM Security Group (SG), Hybrid and Relay Connection Managers, Azure Monitoring and Alarms, SQL Failover, SQL DB Import\Export, ScienceLogic\Remedy ticketing, Key Vault (KV), and SSL • Developed disposability with complete setup and teardown of Notify NYC infrastructure Key Results: • Reduce deployment
    [Show full text]
  • Automated Testing and Continuous Integration for the Deutsche Bank Index Quant Team
    Automated Testing and Continuous Integration for the Deutsche Bank Index Quant Team A Major Qualifying Project Submitted to the faculty of WORCESTER POLYTECHNIC INSTITUTE In partial fulfillment of the requirements for the Degree of Bachelor of Science By Jeccica Doherty [email protected] Tanvir Singh Madan [email protected] Xing Wei [email protected] Date of Submission: January 7, 2009 Abstract The goal of this project was to reduce risks from the applications of the Index Quant team at Deutsche Bank. Because their Index Calculator project is frequently updated, it is important to continuously build the project and check for regression errors. Our task was to deploy and use various existing tools to create both a continuous build system and an automated testing system for this project. By using these tools, we created a comprehensive build system to automatically run the build and the regression tests whenever a change is made to the project code. Acknowledgements We would like to extend sincere thanks to our sponsors for giving us the opportunity to work in their company. This project could not have been completed without Jason Oh, Jenny Sappington, Nikhil Merchant, and Michel Nematnejad, who have spent a lot of their time assisting us with the project. Also, we would like to thank our advisors, Professor Donald Brown, and Professor Daniel Dougherty, who have provided us with constant support and valuable advices throughout the project. Lastly, we would like to thank the people who made this project possible in the first place. They rescued us from jumping on and off from various MQP’s! Our sincere thanks to Professor Art Gerstenfeld and Teddy Cho for this project opportunity.
    [Show full text]
  • Enabling ETL Test Automation in Solution Delivery Teams
    Enabling ETL Test Automation in Solution Delivery Teams Subu Iyer [email protected] Abstract Most companies today deal with lots of data. Typically, this data is in several databases and across multiple applications. Companies also have to work with data from vendors and clients. To integrate data from multiple sources, Extract Transform and Load (ETL) systems are used. These ETL projects are handled by Solution Delivery teams where each project has its own specific requirements and constraints. This makes it very hard for teams to build automated tests and processes around the ETL solutions that would help them consistently deliver high quality solutions on time and on budget. These and a set of outdated tools and practices make testing ETL jobs a time consuming and labor intensive manual process. The lack of automated testing also makes it very difficult to build and deliver incremental changes and this hurts productivity. This paper describes how our team, the Quality Engineering and Specialized Testing (QuEST) team, is driving a change in the way teams build and test ETL jobs at Cambia Health Solutions. We are doing so by engaging with the Solution Delivery teams, setting up automated tests and providing teams hands-on training so they can continue writing automated tests. This paper will also talk about the benefits of building and growing the test framework organically in an incremental fashion. We’ll see how our team was able to overcome initial challenges and improve our ETL testing. Biography Subu Iyer has been working in Software Quality Assurance for 10+ years. Subu believes in building quality upfront and setting up processes that help us deliver quality products.
    [Show full text]
  • Teaching Acceptance Testing in Contexts of Web Systems Development and Game Programming
    Teaching Acceptance Testing in Contexts of Web Systems Development and Game Programming Grigori Melnik University of Calgary/ SAIT Calgary, Alberta, Canada 403-210-9710 [email protected] Abstract. The paper discusses the role of user acceptance testing and describes the experiences of introducing it into different courses from both students’ and instructors’ perspectives. Examples of assigned projects are given. The paper highlights testing as an all-encompassing activity in an academic setting. It also contains recommendations for academics thinking of incorporating user acceptance testing into their courses. 1 Introduction Nowadays, software testing is no longer considered to be a stage of the development life cycle that is done after software construction is completed, with a limited purpose of detecting failures. However, in academic curricula, testing is not always given adequate attention. Even if the role of testing may be discussed in the introductory software engineering courses, the software testing practices themselves are only covered in senior and graduate courses. As a result, students tend to think about testing as something that is done at the end and only if time permits. This paper reports on our experiences of making testing an all-encompassing activity. We encourage educators to introduce testing in software engineering curricula as early as in the first semester of study, consequently making testing more of a requirement specification technique than a traditional pure verification and validation activity. Specifically, we discuss the use of the FIT acceptance testing framework for communicating and testing project requirements in two software engineering courses. 2 Executable Acceptance Testing Acceptance test is a (formal) test conducted to determine whether or not a system satisfies its acceptance criteria and to enable the user (customer) to determine whether or not to accept the system (as defined in [1] and [2]).
    [Show full text]