SlideShare a Scribd company logo
1 of 47
Download to read offline
The three layers of testing
@bartwaardenburg
“We want to deliver high quality
applications for our users while regularly
releasing new features”
00 Static analysis
Static analysis
“Static analysis is the analysis of
software that is performed without
actually executing programs”
“Using Flow or TypeScript could have
prevented 15% of the public bugs for
public projects on GitHub”
http://ttendency.cs.ucl.ac.uk/projects/type_study/documents/type_study.pdf
type MyCustomButtonProps = { text: string };
const MyCustomButton = ({ text }: MyCustomButtonProps) => (
<button>{text}</button>
);
const ButtonContainer = () => (
<MyCustomButton text={['I', 'like', 'turtles']} />
);
“You can have every single variable and
function completely typed and linted but still
have none of your functions doing what they
should be doing”
const a: number = 1;
const b: number = 2;
const multiply = (a: number, b: number): number => a + b;
multiply(a, b);
01
00 Static analysis
Unit testing
Unit testing
“A unit test is a way of testing a unit - the
smallest piece of code that can be logically
isolated in a system”
const multiply = (a: number, b: number): number => a + b;
test('Multiply should return the arguments multiplied', () => {
expect(multiply(4, 3)).toBe(12);
)};
expect(received).toBe(expected)
Expected value to be (using ===):
12
Received:
7
“A snapshot test verifies that a piece of
functionality works the same as it did when
the snapshot was created”
const Button = ({ type }: ButtonProps) => (
<button className={`btn-${type}`} />
);
test('The Button component renders correctly', () => {
const component = renderer.create(
<Button type=”good" />
).toJSON();
expect(component).toMatchSnapshot();
});
PASS src/unit-test.spec.js
✓ The Button component renders correctly (11ms)
FAIL src/unit-test.spec.js
✕ The Button component renders correctly (15ms)
● The Button component renders correctly
expect(value).toMatchSnapshot()
Received value does not match stored snapshot 1.
- Snapshot
+ Received
<button
- className="btn-good"
+ className="btn-bad"
/>
“You can have every single component and
function unit test passing but still have none
of your functions working together like they
should”
const multiply = (a: number, b: number): number => a * b;
const alertNumber = (value: number): void => alert(value);
const ButtonWhichShouldAlertOnClick = () => (
<button
onClick={() => multiply(1, 2)}
onMouseEnter={() => alertNumber(multiply(1, 2))}
>
Multiply
</button>
);
01
02
00 Static analysis
Unit testing
Integration testing
Integration testing
“Integration testing is the phase in software
testing in which individual software modules
are combined and tested as a group”
import { mount } from 'enzyme';
const ButtonWhichShouldAlertOnClick = () => (
<button
onClick={() => multiply(1, 2)}
onMouseEnter={() => alertNumber(multiply(1, 2))}
>
Multiply
</button>
);
alertNumber = jest.fn();
test('The Button component should run a function on click', () => {
const component = mount(<Button type="test" />);
component.find('button').simulate('click');
expect(alertNumber).toHaveBeenCalledTimes(1);
});
FAIL src/integration-test.spec.js
✕ The Button component should run a function on click (22ms)
● The Button component should run a function on click
expect(jest.fn()).toHaveBeenCalledTimes(1)
Expected mock function to have been called one time, but it was called
zero times.
“You can have everything working together
completely as intended but still have an
empty screen for an application”
const multiply = (a: number, b: number): number => a * b;
const alertNumber = (value: number): void => alert(value);
const Button = () => (
<button
onClick={() => alertNumber(multiply(1, 2))}
>Multiply</button>
);
document.querySelector(‘body').style.cssText = 'display: none';
01
02
03
00 Static analysis
Unit testing
Integration testing
User interface testing
User interface testing
“User interface testing is the process of
testing a product's graphical user interface to
ensure it meets its specifications”
tools
• Protractor
• Cypress
• Puppeteer
• Codecept
• Navalia
• Chromeless
• Selenium
• Nightmare
• Nightwatch
• TestCafe
• CasperJS
• TestCafe
import {Chrome} from 'navalia';
import {toMatchImageSnapshot} from 'jest-image-snapshot';
expect.extend({toMatchImageSnapshot});
const chrome = new Chrome();
test('The routing input component should display as expected', async () => {
await chrome.goto('https://www.anwb.nl/verkeer/routeplanner');
await chrome.wait('.ROVE-routing-input');
const screenshot = await chrome.screenshot('.ROVE-routing-input');
await chrome.done();
expect(screenshot).toMatchImageSnapshot();
});
PASS src/components/routing-input-address/tests/RoutingInputAddress.ui-
test.js (7.153s)
✓ The routing input component should display as expected (3671ms)
FAIL src/components/routing-input/tests/RoutingInput.ui-test.js (9.909s)
✕ The routing input component should display as expected (9033ms)
● The routing input component should display as expected
Expected image to match or be a close match to snapshot.
See diff for details:
/Users/p279825/Sites/ANWB/traffic/src/components/routing-
input/tests/__image_snapshots__/__diff_output__/routing-input-ui-test-js-
the-routing-input-component-should-display-as-expected-1-diff.png
import {Chromeless} from 'chromeless';
const chromeless = new Chromeless();
const screenshot = await chromeless
.goto('https://www-ontw.anwb.nl/verkeer/routeplanner')
.screenshot('#routing', {
base64: true,
});
const file = new Buffer(screenshot, 'base64');
expect(file).toMatchImageSnapshot();
await chromeless.end();
const chromeless = new Chromeless({
remote: {
endpointUrl: 'https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/dev’,
apiKey: 'your-api-key-here’,
},
});
“With chromeless you can run hundreds of
browsers in parallel”
“You can easily execute > 100.000 tests for
free in the free tier”
01
02
03
00 Static analysis
Unit testing
Integration testing
User interface testing
thanks & happy testing
@bartwaardenburg

More Related Content

What's hot

Asyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaAsyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaPedro Solá
 
The elements' object model in UIAutomation PowerShell Extensions, part 1
The elements' object model in UIAutomation PowerShell Extensions, part 1The elements' object model in UIAutomation PowerShell Extensions, part 1
The elements' object model in UIAutomation PowerShell Extensions, part 1SoftwareTestingUsingPowerShell.com
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.jsChris Saylor
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Ontico
 
Tools & tricks for testing React applications
Tools & tricks for testing React applications Tools & tricks for testing React applications
Tools & tricks for testing React applications React London Community
 
WinRunner Training
WinRunner TrainingWinRunner Training
WinRunner Trainingsunny.deb
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management ToolPeeyush Ranjan
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamAnton Caceres
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonLars Thorup
 

What's hot (14)

Asyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaAsyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-saga
 
The elements' object model in UIAutomation PowerShell Extensions, part 1
The elements' object model in UIAutomation PowerShell Extensions, part 1The elements' object model in UIAutomation PowerShell Extensions, part 1
The elements' object model in UIAutomation PowerShell Extensions, part 1
 
Testing in JavaScript
Testing in JavaScriptTesting in JavaScript
Testing in JavaScript
 
React native tour
React native tourReact native tour
React native tour
 
PowerShell UIAtomation
PowerShell UIAtomationPowerShell UIAtomation
PowerShell UIAtomation
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.js
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
Tools & tricks for testing React applications
Tools & tricks for testing React applications Tools & tricks for testing React applications
Tools & tricks for testing React applications
 
WinRunner Training
WinRunner TrainingWinRunner Training
WinRunner Training
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
 
Java awt
Java awtJava awt
Java awt
 
Swtbot
SwtbotSwtbot
Swtbot
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and Sinon
 

Similar to The three layers of testing for high-quality apps

Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Andrew Eisenberg
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorialKaty Slemon
 
Test driven development with react
Test driven development with reactTest driven development with react
Test driven development with reactLeon Bezuidenhout
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
Testing APEX apps At A Glance
Testing APEX apps At A GlanceTesting APEX apps At A Glance
Testing APEX apps At A GlanceKai Donato
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...Andrey Karpov
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingMax Kleiner
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingAnna Khabibullina
 
Testing in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement BardejovTesting in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement BardejovMarian Rusnak
 
Introduction to AWS Step Functions:
Introduction to AWS Step Functions: Introduction to AWS Step Functions:
Introduction to AWS Step Functions: Amazon Web Services
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期增强 杜
 
Mobile developer is Software developer
Mobile developer is Software developerMobile developer is Software developer
Mobile developer is Software developerEugen Martynov
 
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVP
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVPMicrosoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVP
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVPGilbok Lee
 

Similar to The three layers of testing for high-quality apps (20)

Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
 
Test driven development with react
Test driven development with reactTest driven development with react
Test driven development with react
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Testing APEX apps At A Glance
Testing APEX apps At A GlanceTesting APEX apps At A Glance
Testing APEX apps At A Glance
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testing
 
Testing in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement BardejovTesting in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement Bardejov
 
Introduction to AWS Step Functions:
Introduction to AWS Step Functions: Introduction to AWS Step Functions:
Introduction to AWS Step Functions:
 
杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期杜增强-Flex3组件生命周期
杜增强-Flex3组件生命周期
 
Mobile developer is Software developer
Mobile developer is Software developerMobile developer is Software developer
Mobile developer is Software developer
 
Frontend training
Frontend trainingFrontend training
Frontend training
 
Day 5
Day 5Day 5
Day 5
 
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVP
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVPMicrosoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVP
Microsoft MVP ComCamp 2014 발표자료 / 윈도우 8.1 앱개발 새로운 API들 / 이길복, 주신영 MVP
 

Recently uploaded

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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

The three layers of testing for high-quality apps

  • 1. The three layers of testing @bartwaardenburg
  • 2. “We want to deliver high quality applications for our users while regularly releasing new features”
  • 3.
  • 4.
  • 7. “Static analysis is the analysis of software that is performed without actually executing programs”
  • 8. “Using Flow or TypeScript could have prevented 15% of the public bugs for public projects on GitHub” http://ttendency.cs.ucl.ac.uk/projects/type_study/documents/type_study.pdf
  • 9. type MyCustomButtonProps = { text: string }; const MyCustomButton = ({ text }: MyCustomButtonProps) => ( <button>{text}</button> ); const ButtonContainer = () => ( <MyCustomButton text={['I', 'like', 'turtles']} /> );
  • 10.
  • 11. “You can have every single variable and function completely typed and linted but still have none of your functions doing what they should be doing”
  • 12. const a: number = 1; const b: number = 2; const multiply = (a: number, b: number): number => a + b; multiply(a, b);
  • 15. “A unit test is a way of testing a unit - the smallest piece of code that can be logically isolated in a system”
  • 16. const multiply = (a: number, b: number): number => a + b; test('Multiply should return the arguments multiplied', () => { expect(multiply(4, 3)).toBe(12); )};
  • 17. expect(received).toBe(expected) Expected value to be (using ===): 12 Received: 7
  • 18. “A snapshot test verifies that a piece of functionality works the same as it did when the snapshot was created”
  • 19. const Button = ({ type }: ButtonProps) => ( <button className={`btn-${type}`} /> ); test('The Button component renders correctly', () => { const component = renderer.create( <Button type=”good" /> ).toJSON(); expect(component).toMatchSnapshot(); });
  • 20. PASS src/unit-test.spec.js ✓ The Button component renders correctly (11ms)
  • 21. FAIL src/unit-test.spec.js ✕ The Button component renders correctly (15ms) ● The Button component renders correctly expect(value).toMatchSnapshot() Received value does not match stored snapshot 1. - Snapshot + Received <button - className="btn-good" + className="btn-bad" />
  • 22. “You can have every single component and function unit test passing but still have none of your functions working together like they should”
  • 23. const multiply = (a: number, b: number): number => a * b; const alertNumber = (value: number): void => alert(value); const ButtonWhichShouldAlertOnClick = () => ( <button onClick={() => multiply(1, 2)} onMouseEnter={() => alertNumber(multiply(1, 2))} > Multiply </button> );
  • 24. 01 02 00 Static analysis Unit testing Integration testing
  • 26. “Integration testing is the phase in software testing in which individual software modules are combined and tested as a group”
  • 27. import { mount } from 'enzyme'; const ButtonWhichShouldAlertOnClick = () => ( <button onClick={() => multiply(1, 2)} onMouseEnter={() => alertNumber(multiply(1, 2))} > Multiply </button> ); alertNumber = jest.fn(); test('The Button component should run a function on click', () => { const component = mount(<Button type="test" />); component.find('button').simulate('click'); expect(alertNumber).toHaveBeenCalledTimes(1); });
  • 28. FAIL src/integration-test.spec.js ✕ The Button component should run a function on click (22ms) ● The Button component should run a function on click expect(jest.fn()).toHaveBeenCalledTimes(1) Expected mock function to have been called one time, but it was called zero times.
  • 29. “You can have everything working together completely as intended but still have an empty screen for an application”
  • 30. const multiply = (a: number, b: number): number => a * b; const alertNumber = (value: number): void => alert(value); const Button = () => ( <button onClick={() => alertNumber(multiply(1, 2))} >Multiply</button> ); document.querySelector(‘body').style.cssText = 'display: none';
  • 31. 01 02 03 00 Static analysis Unit testing Integration testing User interface testing
  • 33. “User interface testing is the process of testing a product's graphical user interface to ensure it meets its specifications”
  • 34. tools • Protractor • Cypress • Puppeteer • Codecept • Navalia • Chromeless • Selenium • Nightmare • Nightwatch • TestCafe • CasperJS • TestCafe
  • 35. import {Chrome} from 'navalia'; import {toMatchImageSnapshot} from 'jest-image-snapshot'; expect.extend({toMatchImageSnapshot}); const chrome = new Chrome(); test('The routing input component should display as expected', async () => { await chrome.goto('https://www.anwb.nl/verkeer/routeplanner'); await chrome.wait('.ROVE-routing-input'); const screenshot = await chrome.screenshot('.ROVE-routing-input'); await chrome.done(); expect(screenshot).toMatchImageSnapshot(); });
  • 36.
  • 37. PASS src/components/routing-input-address/tests/RoutingInputAddress.ui- test.js (7.153s) ✓ The routing input component should display as expected (3671ms)
  • 38.
  • 39. FAIL src/components/routing-input/tests/RoutingInput.ui-test.js (9.909s) ✕ The routing input component should display as expected (9033ms) ● The routing input component should display as expected Expected image to match or be a close match to snapshot. See diff for details: /Users/p279825/Sites/ANWB/traffic/src/components/routing- input/tests/__image_snapshots__/__diff_output__/routing-input-ui-test-js- the-routing-input-component-should-display-as-expected-1-diff.png
  • 40.
  • 41. import {Chromeless} from 'chromeless'; const chromeless = new Chromeless(); const screenshot = await chromeless .goto('https://www-ontw.anwb.nl/verkeer/routeplanner') .screenshot('#routing', { base64: true, }); const file = new Buffer(screenshot, 'base64'); expect(file).toMatchImageSnapshot(); await chromeless.end();
  • 42.
  • 43. const chromeless = new Chromeless({ remote: { endpointUrl: 'https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/dev’, apiKey: 'your-api-key-here’, }, });
  • 44. “With chromeless you can run hundreds of browsers in parallel”
  • 45. “You can easily execute > 100.000 tests for free in the free tier”
  • 46. 01 02 03 00 Static analysis Unit testing Integration testing User interface testing
  • 47. thanks & happy testing @bartwaardenburg