SlideShare une entreprise Scribd logo
1  sur  23
Creating Data with the Test Data
Builder Pattern
CukeUp! 2013
Alan Parkinson
Create test data with the most
appropriate tools and
using a sensible DSL
Scenario AUT
Database
Build method
Safe Defaults
Chainable
public class UserBuilder {
String name = “admin”;
String password = “admin”;
…
public User build() {
return new User(admin, password);
}
…
}
User user = new UserBuilder() .build();
User user = new UserBuilder()
.withName(“Alan”)
.withPassword(“secret”).build();
Build method
Safe Defaults
Chainable
Imperative Example
Given a User "dave" exists with password "secret"
And I am not logged in
When I navigate to the home page
Then I am redirected to the login form
....
Refactored to be Declarative
Given I am an unauthenticated User
When I attempt to view some restricted content
Then I am shown a login form
When I authenticate with valid credentials
….
private UserDescription user;
@Given("^I am an … $")
public void unauthenticated_user() {
user = new UserBuilder().build();
…
}
Declarative Example
private UserDescription user;
@Given("^ a User … $")
public void a_user(String name, password) {
user = new UserBuilder()
.withName(name)
.withPassword(password).build();
}
private UserDescription user;
private UserBuilder userBuilder = new UserBuilder();
@Given("^I am an … $")
public void unauthenticated_user() {
user = userBuilder.build();
}
@Given("^an email address $")
public void user_email(String emailAddress) {
userBuilder.withEmail(emailAddress);
user = userBuilder.build();
}
public class IssueBuilder {
String summary = “Default Summary”;
Project project = new ProjectBuilder().build();
String reporter = new UserBuilder().build();
…
public IssueBuilder withProject(Project project) {
this.project = project;
return this;
}
public IssueDescription build() {…}
}
Issue issue = new IssueBuilder()
.withSummary(“Icon hover bug”).build();
.withReporter(
new UserBuilder().withName(“Alan”)
.build())
.build();
public class IssueBuilder {
…
Project project = null;
…
public IssueDescription build() {
if (project == null) {
project = new ProjectBuilder().build();
}
…
}
}
Unique
Factories
Create test data with the most
appropriate tools and
using a sensible DSL
Questions
Alan Parkinson
CEO, Hindsight Software Ltd
alan.parkinson@hindsightsoftware.co.uk
@alan_parkinson
Links
Test Data Builders: an alternate to the Object
Mother pattern - http://ow.ly/jEYkf
NatPryce.com

Contenu connexe

Tendances

Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core DataMake School
 
Building a Backend with Flask
Building a Backend with FlaskBuilding a Backend with Flask
Building a Backend with FlaskMake School
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsRichie Rump
 
01 session tracking
01   session tracking01   session tracking
01 session trackingdhrubo kayal
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoMoldova ICT Summit
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOSMake School
 
How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...Syed Farjad Zia Zaidi
 
An Introduction to Quill
An Introduction to QuillAn Introduction to Quill
An Introduction to QuillKnoldus Inc.
 
Labs And Walkthroughs
Labs And WalkthroughsLabs And Walkthroughs
Labs And WalkthroughsBryan Tuttle
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity FrameworkMahmoud Tolba
 
Rabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPressRabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPresswpnepal
 
Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on JavaMax Titov
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805LearningTech
 
Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOSMake School
 

Tendances (20)

Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core Data
 
Building a Backend with Flask
Building a Backend with FlaskBuilding a Backend with Flask
Building a Backend with Flask
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
Core Data
Core DataCore Data
Core Data
 
01 session tracking
01   session tracking01   session tracking
01 session tracking
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai Shevchenko
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOS
 
How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
An Introduction to Quill
An Introduction to QuillAn Introduction to Quill
An Introduction to Quill
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Labs And Walkthroughs
Labs And WalkthroughsLabs And Walkthroughs
Labs And Walkthroughs
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
Presentation
PresentationPresentation
Presentation
 
Rabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPressRabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPress
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on Java
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805
 
Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOS
 

Similaire à Creating data with the test data builder pattern

Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoRodrigo Urubatan
 
Android and firebase database
Android and firebase databaseAndroid and firebase database
Android and firebase databaseNILESH SAWARDEKAR
 
第一次用Parse就深入淺出
第一次用Parse就深入淺出第一次用Parse就深入淺出
第一次用Parse就深入淺出Ymow Wu
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemAzharul Haque Shohan
 
Security in laravel
Security in laravelSecurity in laravel
Security in laravelSayed Ahmed
 
Continuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with seleniumContinuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with seleniumXebia IT Architects
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreRyan Weaver
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resourcesJavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resourcesCorley S.r.l.
 
From 0 to Spring Security 4.0
From 0 to Spring Security 4.0From 0 to Spring Security 4.0
From 0 to Spring Security 4.0robwinch
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase AuthPeter Friese
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysqlKnoldus Inc.
 
InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)Andrea Bizzotto
 
Lesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdfLesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdfScott Anderson
 

Similaire à Creating data with the test data builder pattern (17)

Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicação
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Android and firebase database
Android and firebase databaseAndroid and firebase database
Android and firebase database
 
第一次用Parse就深入淺出
第一次用Parse就深入淺出第一次用Parse就深入淺出
第一次用Parse就深入淺出
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
Security in laravel
Security in laravelSecurity in laravel
Security in laravel
 
Continuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with seleniumContinuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with selenium
 
Spring Security 3
Spring Security 3Spring Security 3
Spring Security 3
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resourcesJavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
 
From 0 to Spring Security 4.0
From 0 to Spring Security 4.0From 0 to Spring Security 4.0
From 0 to Spring Security 4.0
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
 
InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)
 
Lesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdfLesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdf
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 

Plus de Alan Parkinson

Testing requirements with BDD
Testing requirements with BDDTesting requirements with BDD
Testing requirements with BDDAlan Parkinson
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppetAlan Parkinson
 
Decapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptDecapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptAlan Parkinson
 
Pull requests and testers can be friends
Pull requests and testers can be friendsPull requests and testers can be friends
Pull requests and testers can be friendsAlan Parkinson
 
What is Continuous Delivery?
What is Continuous Delivery?What is Continuous Delivery?
What is Continuous Delivery?Alan Parkinson
 
Cross browser Testing JavaScript
Cross browser Testing JavaScriptCross browser Testing JavaScript
Cross browser Testing JavaScriptAlan Parkinson
 
Why we used Feature Branching
Why we used Feature BranchingWhy we used Feature Branching
Why we used Feature BranchingAlan Parkinson
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVMAlan Parkinson
 
A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)Alan Parkinson
 
Cross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptCross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptAlan Parkinson
 
Acceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAcceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAlan Parkinson
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenAlan Parkinson
 
Feature branching a release day painkiller
Feature branching   a release day painkillerFeature branching   a release day painkiller
Feature branching a release day painkillerAlan Parkinson
 

Plus de Alan Parkinson (13)

Testing requirements with BDD
Testing requirements with BDDTesting requirements with BDD
Testing requirements with BDD
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppet
 
Decapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptDecapitating Selenium with JavaScript
Decapitating Selenium with JavaScript
 
Pull requests and testers can be friends
Pull requests and testers can be friendsPull requests and testers can be friends
Pull requests and testers can be friends
 
What is Continuous Delivery?
What is Continuous Delivery?What is Continuous Delivery?
What is Continuous Delivery?
 
Cross browser Testing JavaScript
Cross browser Testing JavaScriptCross browser Testing JavaScript
Cross browser Testing JavaScript
 
Why we used Feature Branching
Why we used Feature BranchingWhy we used Feature Branching
Why we used Feature Branching
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)
 
Cross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptCross-browser unit testing JavaScript
Cross-browser unit testing JavaScript
 
Acceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAcceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs Declarative
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Feature branching a release day painkiller
Feature branching   a release day painkillerFeature branching   a release day painkiller
Feature branching a release day painkiller
 

Dernier

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Creating data with the test data builder pattern

Notes de l'éditeur

  1. HowWhenWhy
  2. To isolate data between tests, script cleans and populates the databaseRequires direct access to the database
  3. SQL Scripts are brittle to changePortability issues between database vendorsHigh maintenance costDifficult to create dataHard write by handSmall sets of data created – often reused across many tests.Run Application, add data and create Script from Database DumpLots of small variationsFor large sets of tests data schema changes are expensiveCan’t be used with Concurrent / Parallel Test ExecutionIgnores business rules on data – Script my load data that does not follow the correct business rules, cause test to fail. Hard to debugLimits reuse of Test artifactsCan’t access databases on production systems - NO smoke testing deployments –
  4. Our Applications expose API’s all the timeREST, SOAP and RMI to name a fewUse them to create our test dataOn Demand – Given StepDevelopers maintain the public API – receives free maintenanceCode reuse – Code can be reused for Testing the REST services.Tests can be reused for Smoke testing deploymentsAs it doesn't clean the database. Requires generated data to be uniqueIgnores system state - the same tests can be repeatedly executed with the same result
  5. Public API code - Large messy code for creating test data on demandNice abstraction is requiredReadable test setup codeCode reuseEasy and low maintenanceNat PryceCreate a builder for each class or resourceHas an instance variable for each constructor parameterInitialises its instance variables to commonly used or safe valuesHas a `build` method that creates a new object using the values in its instance variablesHas "chainable" public methods for overriding the values in its instance variables.
  6. Simplest example of a builder used in Unit testsAll builders feature a build method - No parametersReturns value objectInstead we would make REST/API calls to our
  7. Sensible defaults Click - Can be overriddenWritten a fluent styleEasy to read
  8. Returns object describing the remotely created datae.g. unique IDIssueBuilder would return the Key of the created Issue.Even if the Any other useful information that is required by the test
  9. The imperative style uses highly reusable granular steps which outlines much of the user interface. This binds the scenario to that UI and requires more design decisions made up front.Makes the Scenario brittle to minor changes in UI when no Behaviour or functionality has changed.
  10. Each step states an idea.Sometimes it’s not really clear precisely what is being doneThe username and password detail has been pushed inside the test implementationWe don’t care about these details in this example – It doesn’t add anythingUse sensible defaults for these values – Data Builder also uses sensible defaults.
  11. RelationshipsRefactor build method to lazily initialize
  12. Sensible defaults Can be overriddenWritten a fluent styleEasy to readEmbedding builders
  13. As we are creating remote objects, defaults should lazily initialized to avoid performance penalty
  14. ID’s are best generated - previously run the same test suite and have not cleared the database, manually created unique ID’s could already be in use.Randomness - Repeating the test should not generate the same IDWe have found Hashes work quite well for Alphanumeric generationIssue – generates unique ID in the dataProject – requires us to generate a unique IDProject ID is up to 10 characters long and Alpha onlyGenerated IDs avoid clashes with stale dataHashes – MD5Seeding data generation ImportantTest method name useful componentRandom numberBusiness rules – Data length and typeAlpha only string generator
  15. Different product versions/configurationsDifferent data formatsDifferent devicesCan be supported by the Abstract Factory patternCreate families of builders to support them
  16. Avoid SQLUse exposed API’sGenerate Unique dataData Builder PatternFactories for your Data Builders
  17. Test Data Builders: an alternate to the Object Mother patternCreate objects with complex constructors in Unit TestsHas an instance variable for each constructor parameterInitialises its instance variables to commonly used or safe valuesHas a `build` method that creates a new object using the values in its instance variablesHas "chainable" public methods for overriding the values in its instance variables.