SlideShare a Scribd company logo
MockServer-driven
testing
Alexey Alter-Pesotskiy
Stream
2
in/testableapple
testableapple
testableapple.com
Me, Myself & I
3
Mobile Automation Newsletter
testableapple.com/newsletter
4
How They Automate on Mobile
testableapple.com/big-tech
5
6
1. Introduction to «MockServer-driven testing» methodology
1. Proof of Concept
❏ Creating Native Mock Server
❏ Creating Standalone Mock Server
1. Showcasing the methodology on the real project
Contents
7
MockServer-Driven Testing
MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests,
which is a custom branch of the Test Driven Development (TDD) methodology.
8
MockServer-Driven Testing
MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests,
which is a custom branch of the Test Driven Development (TDD) methodology.
The main idea is:
❏ To create a mock server that completely replaces the real backend
❏ To cover the features supported by a mock server with automated UI tests
9
MockServer-Driven Testing
MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests,
which is a custom branch of the Test Driven Development (TDD) methodology.
The main idea is:
❏ To create a mock server that completely replaces the real backend
❏ To cover the features supported by a mock server with automated UI tests
TDD vs MSDT:
❏ TDD: developing unit tests to write application source code
❏ MSDT: developing mock server to write UI tests
10
MockServer-Driven Testing
11
MSDT
12
MSDT
13
Pros
14
● Automated testing of the frontend does not depend on the backend state
Pros
15
● Automated testing of the frontend does not depend on the backend state
● The tests’ speed is much higher because:
○ What requires a lot of hustle on the UI can be eliminated from the tests
○ What requires customizations on the backend can be driven from tests
○ What weighs a lot from the network perspective can work instantly
Pros
16
● Automated testing of the frontend does not depend on the backend state
● The tests’ speed is much higher because:
○ What requires a lot of hustle on the UI can be eliminated from the tests
○ What requires customizations on the backend can be driven from tests
○ What weighs a lot from the network perspective can work instantly
● Mock server can "open up" the opportunity to write interesting test scenarios (mostly
negative ones though)
Pros
17
● Automated testing of the frontend does not depend on the backend state
● The tests’ speed is much higher because:
○ What requires a lot of hustle on the UI can be eliminated from the tests
○ What requires customizations on the backend can be driven from tests
○ What weighs a lot from the network perspective can work instantly
● Mock server can "open up" the opportunity to write interesting test scenarios (mostly
negative ones though)
● Tests can check not only the UI reflection of responses from the server, but also the
requests to the server itself
Pros
18
● Automated testing of the frontend does not depend on the backend state
● The tests’ speed is much higher because:
○ What requires a lot of hustle on the UI can be eliminated from the tests
○ What requires customizations on the backend can be driven from tests
○ What weighs a lot from the network perspective can work instantly
● Mock server can "open up" the opportunity to write interesting test scenarios (mostly
negative ones though)
● Tests can check not only the UI reflection of responses from the server, but also the
requests to the server itself
● Developers can participate/assist in creating both the mock server and the tests
Pros
19
Cons
20
● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock
server
Cons
21
● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock
server
● 🐛 There's a possibility of bugs in the mock server
Cons
22
● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock
server
● 🐛 There's a possibility of bugs in the mock server
● 🏃♂️ There's a chance the real backend will run off ahead
Cons
23
Use cases
1. You're only interested in testing the frontend
24
Use cases
1. You're only interested in testing the frontend
1. You want to manage the backend on the fly
○ e.g.: mock images, banner ads, etc.
Use cases
25
1. You're only interested in testing the frontend
1. You want to manage the backend on the fly
○ e.g.: mock images, banner ads, etc.
1. In tests you’d like to see/catch requests flying off the device
○ e.g.: analytics, custom events, etc.
26
Use cases
1. You're only interested in testing the frontend
1. You want to manage the backend on the fly
○ e.g.: mock images, banner ads, etc.
1. In tests you’d like to see/catch requests flying off the device
○ e.g.: analytics, custom events, etc.
1. You need to emulate the interaction of several users
○ e.g.: chat, games, etc.
27
Use cases
1. You're only interested in testing the frontend
1. You want to manage the backend on the fly
○ e.g.: mock images, banner ads, etc.
1. In tests you’d like to see/catch requests flying off the device
○ e.g.: analytics, custom events, etc.
1. You need to emulate the interaction of several users
○ e.g.: chat, games, etc.
1. ...
28
Use cases
29
How we came to MSDT
30
Brief overview of the development process
31
Brief overview of the development process
32
Brief overview of the development process
33
GitHub Actions
Brief overview of the development process
34
GitHub Actions
Brief overview of the development process
35
GitHub Actions
XCTest
Brief overview of the development process
36
GitHub Actions
XCTest
Brief overview of the development process
37
GitHub Actions
Swift
Package
Manager
Carthage
XCTest
Brief overview of the development process
We need autotests covering the UI:
a. Incoming/outgoing messages, reactions, attachments, etc.
b. Online/offline
c. In background/foreground
d. On all supported iOS versions
38
Problem statement
39
Proposed solutions
1. Use two devices/simulators at the same time
40
Proposed solutions
1. Use two devices/simulators at the same time
1. Create an autoresponder on the backend
41
Proposed solutions
1. Use two devices/simulators at the same time
1. Create an autoresponder on the backend
1. Develop a mock server to simulate the backend and the second participant in chat
42
Proposed solutions
1. Use two devices/simulators at the same time
1. Create an autoresponder on the backend
1. Develop a mock server to simulate the backend and the second participant in chat
43
Proposed solutions
44
Native or Standalone?
45
Native Standalone
Same programming language used in
development, follows the same code style
Mock Server
46
Native Standalone
Same programming language used in
development, follows the same code style
Lives in the same project
Mock Server
47
Native Standalone
Same programming language used in
development, follows the same code style
Lives in the same project
Easier to debug
Mock Server
48
Native Standalone
Same programming language used in
development, follows the same code style
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Mock Server
49
Native Standalone
Same programming language used in
development, follows the same code style
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Parallelization out of the box
Mock Server
50
Native Standalone
Same programming language used in
development, follows the same code style
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Parallelization out of the box
Works like a charm on CI
Mock Server
51
Native Standalone
Same programming language used in
development, follows the same code style
Cross-Platform
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Parallelization out of the box
Works like a charm on CI
Mock Server
52
Native Standalone
Same programming language used in
development, follows the same code style
Cross-Platform
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Parallelization out of the box
Works like a charm on CI
Requires synchronization with the real backend
Mock Server
53
Native Standalone
Same programming language used in
development, follows the same code style
Cross-Platform
Lives in the same project
Easier to debug
Doesn’t require separate network requests
(everything is controlled from tests)
Parallelization out of the box
Works like a charm on CI
Requires synchronization with the real backend
iOS: swifter, Android: http4k, okhttp, ktor rb: sinatra, js: express, py: flask, go: gin …
Mock Server
54
Mock Server
55
Proof of Concept
56
Stream Chat Mock Server
57
58
59
60
61
62
63
Key points of implementation
● Mock server
○ crafted using swifter
64
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
65
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
○ runs on localhost
66
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
○ runs on localhost
● Tests
○ do not look at the real backend
67
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
○ runs on localhost
● Tests
○ do not look at the real backend
○ independent from each other because the mock server turns on before and
turns off after every test
68
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
○ runs on localhost
● Tests
○ do not look at the real backend
○ independent from each other because the mock server turns on before and
turns off after every test
● We
○ use Launch arguments and Environment variables to redirect the app to the
correct server (the mock or production one)
69
Key points of implementation
● Mock server
○ crafted using swifter
○ works with HTTP as well as with Websocket
○ runs on localhost
● Tests
○ do not look at the real backend
○ independent from each other because the mock server turns on before and
turns off after every test
● We
○ use Launch arguments and Environment variables to redirect the app to the
correct server (the mock or production one)
○ keep golden responses from the backend in the repo and use them as
templates, to change/update on the fly during the tests
70
Key points of implementation
Challenge
Redirect SDK to the mock server
71
Pitfalls
Challenge
Redirect SDK to the mock server #if … #endif
72
Pitfalls
73
source file
74
source file
Challenge
Redirect SDK to the mock server #if … #endif
Share the codebase with SwiftUI
75
Pitfalls
Challenge
Redirect SDK to the mock server #if … #endif
Share the codebase with SwiftUI Swift Package Manager
76
Pitfalls
77
source file
78
source file
79
source file
80
source file
Challenge
Redirect SDK to the mock server #if … #endif
Share the codebase with SwiftUI Swift Package Manager
Sync mock server with the backend
81
Pitfalls
Challenge
Redirect SDK to the mock server #if … #endif
Share the codebase with SwiftUI Swift Package Manager
Sync mock server with the backend Stream Chat API
82
Pitfalls
83
source file
84
source file
85
source file
86
source file
87
source file
88
source file
89
source file
90
source file
91
source file
92
source file
93
source file
94
source file
95
source file
96
source file
Sample test
97
source file
Sample test
98
source file
Sample test
99
source file
Sample test
100
source file
Sample test
101
source file
Sample test
102
source file
Sample test
103
Android
104
Android
swifter
105
Android
swifter
❏ http4k
❏ okhttp
❏ ktor
106
Android
● testableapple.com/native-mock-server-inside-xctest
● github.com/testableapple/mockserver-driven-testing
● github.com/GetStream/stream-chat-swift
● github.com/GetStream/stream-chat-swiftui
107
Useful links
Cheers!
in/testableapple
testableapple
testableapple.com

More Related Content

Similar to MockServer-driven testing

Software Testing
Software TestingSoftware Testing
Software Testing
Andrew Wang
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
Aleksandr Tarasov
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
Lars Thorup
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testingBestBrains
 
Expedia 3x3 presentation
Expedia 3x3 presentationExpedia 3x3 presentation
Expedia 3x3 presentation
Drew Hannay
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker
 
Test automation proposal
Test automation proposalTest automation proposal
Test automation proposal
Mihai-Cristian Fratila
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test Automation
Knoldus Inc.
 
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and TacticalTLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
Anna Royzman
 
Real time web
Real time webReal time web
Real time web
Medhat Dawoud
 
Automating development-operations-v1
Automating development-operations-v1Automating development-operations-v1
Automating development-operations-v1Sumanth Vepa
 
Develop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConfDevelop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConf
Annyce Davis
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
ikram_ahamed
 
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Applitools
 
Встреча "QA: в каких направлениях может найти себя тестировщик?"
Встреча "QA: в каких направлениях может найти себя тестировщик?"Встреча "QA: в каких направлениях может найти себя тестировщик?"
Встреча "QA: в каких направлениях может найти себя тестировщик?"
GoIT
 
Building High Quality Android Applications
Building High Quality Android ApplicationsBuilding High Quality Android Applications
Building High Quality Android Applications
Leif Janzik
 
A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)
Oursky
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at Snyk
Anton Drukh
 

Similar to MockServer-driven testing (20)

Software Testing
Software TestingSoftware Testing
Software Testing
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
 
Expedia 3x3 presentation
Expedia 3x3 presentationExpedia 3x3 presentation
Expedia 3x3 presentation
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
 
Test automation proposal
Test automation proposalTest automation proposal
Test automation proposal
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test Automation
 
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and TacticalTLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
 
Real time web
Real time webReal time web
Real time web
 
CI
CICI
CI
 
Automating development-operations-v1
Automating development-operations-v1Automating development-operations-v1
Automating development-operations-v1
 
Develop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConfDevelop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConf
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
 
Встреча "QA: в каких направлениях может найти себя тестировщик?"
Встреча "QA: в каких направлениях может найти себя тестировщик?"Встреча "QA: в каких направлениях может найти себя тестировщик?"
Встреча "QA: в каких направлениях может найти себя тестировщик?"
 
Building High Quality Android Applications
Building High Quality Android ApplicationsBuilding High Quality Android Applications
Building High Quality Android Applications
 
A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at Snyk
 

Recently uploaded

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
ambekarshweta25
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 

Recently uploaded (20)

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 

MockServer-driven testing

  • 4. 4 How They Automate on Mobile testableapple.com/big-tech
  • 5. 5
  • 6. 6 1. Introduction to «MockServer-driven testing» methodology 1. Proof of Concept ❏ Creating Native Mock Server ❏ Creating Standalone Mock Server 1. Showcasing the methodology on the real project Contents
  • 8. MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests, which is a custom branch of the Test Driven Development (TDD) methodology. 8 MockServer-Driven Testing
  • 9. MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests, which is a custom branch of the Test Driven Development (TDD) methodology. The main idea is: ❏ To create a mock server that completely replaces the real backend ❏ To cover the features supported by a mock server with automated UI tests 9 MockServer-Driven Testing
  • 10. MockServer-Driven Testing (MSDT) is a methodology for developing automated UI tests, which is a custom branch of the Test Driven Development (TDD) methodology. The main idea is: ❏ To create a mock server that completely replaces the real backend ❏ To cover the features supported by a mock server with automated UI tests TDD vs MSDT: ❏ TDD: developing unit tests to write application source code ❏ MSDT: developing mock server to write UI tests 10 MockServer-Driven Testing
  • 14. 14 ● Automated testing of the frontend does not depend on the backend state Pros
  • 15. 15 ● Automated testing of the frontend does not depend on the backend state ● The tests’ speed is much higher because: ○ What requires a lot of hustle on the UI can be eliminated from the tests ○ What requires customizations on the backend can be driven from tests ○ What weighs a lot from the network perspective can work instantly Pros
  • 16. 16 ● Automated testing of the frontend does not depend on the backend state ● The tests’ speed is much higher because: ○ What requires a lot of hustle on the UI can be eliminated from the tests ○ What requires customizations on the backend can be driven from tests ○ What weighs a lot from the network perspective can work instantly ● Mock server can "open up" the opportunity to write interesting test scenarios (mostly negative ones though) Pros
  • 17. 17 ● Automated testing of the frontend does not depend on the backend state ● The tests’ speed is much higher because: ○ What requires a lot of hustle on the UI can be eliminated from the tests ○ What requires customizations on the backend can be driven from tests ○ What weighs a lot from the network perspective can work instantly ● Mock server can "open up" the opportunity to write interesting test scenarios (mostly negative ones though) ● Tests can check not only the UI reflection of responses from the server, but also the requests to the server itself Pros
  • 18. 18 ● Automated testing of the frontend does not depend on the backend state ● The tests’ speed is much higher because: ○ What requires a lot of hustle on the UI can be eliminated from the tests ○ What requires customizations on the backend can be driven from tests ○ What weighs a lot from the network perspective can work instantly ● Mock server can "open up" the opportunity to write interesting test scenarios (mostly negative ones though) ● Tests can check not only the UI reflection of responses from the server, but also the requests to the server itself ● Developers can participate/assist in creating both the mock server and the tests Pros
  • 20. 20 ● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock server Cons
  • 21. 21 ● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock server ● 🐛 There's a possibility of bugs in the mock server Cons
  • 22. 22 ● 👷♂️ We need to consider the costs of creating/implementing/maintaining a mock server ● 🐛 There's a possibility of bugs in the mock server ● 🏃♂️ There's a chance the real backend will run off ahead Cons
  • 24. 1. You're only interested in testing the frontend 24 Use cases
  • 25. 1. You're only interested in testing the frontend 1. You want to manage the backend on the fly ○ e.g.: mock images, banner ads, etc. Use cases 25
  • 26. 1. You're only interested in testing the frontend 1. You want to manage the backend on the fly ○ e.g.: mock images, banner ads, etc. 1. In tests you’d like to see/catch requests flying off the device ○ e.g.: analytics, custom events, etc. 26 Use cases
  • 27. 1. You're only interested in testing the frontend 1. You want to manage the backend on the fly ○ e.g.: mock images, banner ads, etc. 1. In tests you’d like to see/catch requests flying off the device ○ e.g.: analytics, custom events, etc. 1. You need to emulate the interaction of several users ○ e.g.: chat, games, etc. 27 Use cases
  • 28. 1. You're only interested in testing the frontend 1. You want to manage the backend on the fly ○ e.g.: mock images, banner ads, etc. 1. In tests you’d like to see/catch requests flying off the device ○ e.g.: analytics, custom events, etc. 1. You need to emulate the interaction of several users ○ e.g.: chat, games, etc. 1. ... 28 Use cases
  • 29. 29 How we came to MSDT
  • 30. 30 Brief overview of the development process
  • 31. 31 Brief overview of the development process
  • 32. 32 Brief overview of the development process
  • 33. 33 GitHub Actions Brief overview of the development process
  • 34. 34 GitHub Actions Brief overview of the development process
  • 35. 35 GitHub Actions XCTest Brief overview of the development process
  • 36. 36 GitHub Actions XCTest Brief overview of the development process
  • 38. We need autotests covering the UI: a. Incoming/outgoing messages, reactions, attachments, etc. b. Online/offline c. In background/foreground d. On all supported iOS versions 38 Problem statement
  • 40. 1. Use two devices/simulators at the same time 40 Proposed solutions
  • 41. 1. Use two devices/simulators at the same time 1. Create an autoresponder on the backend 41 Proposed solutions
  • 42. 1. Use two devices/simulators at the same time 1. Create an autoresponder on the backend 1. Develop a mock server to simulate the backend and the second participant in chat 42 Proposed solutions
  • 43. 1. Use two devices/simulators at the same time 1. Create an autoresponder on the backend 1. Develop a mock server to simulate the backend and the second participant in chat 43 Proposed solutions
  • 45. 45 Native Standalone Same programming language used in development, follows the same code style Mock Server
  • 46. 46 Native Standalone Same programming language used in development, follows the same code style Lives in the same project Mock Server
  • 47. 47 Native Standalone Same programming language used in development, follows the same code style Lives in the same project Easier to debug Mock Server
  • 48. 48 Native Standalone Same programming language used in development, follows the same code style Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Mock Server
  • 49. 49 Native Standalone Same programming language used in development, follows the same code style Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Parallelization out of the box Mock Server
  • 50. 50 Native Standalone Same programming language used in development, follows the same code style Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Parallelization out of the box Works like a charm on CI Mock Server
  • 51. 51 Native Standalone Same programming language used in development, follows the same code style Cross-Platform Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Parallelization out of the box Works like a charm on CI Mock Server
  • 52. 52 Native Standalone Same programming language used in development, follows the same code style Cross-Platform Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Parallelization out of the box Works like a charm on CI Requires synchronization with the real backend Mock Server
  • 53. 53 Native Standalone Same programming language used in development, follows the same code style Cross-Platform Lives in the same project Easier to debug Doesn’t require separate network requests (everything is controlled from tests) Parallelization out of the box Works like a charm on CI Requires synchronization with the real backend iOS: swifter, Android: http4k, okhttp, ktor rb: sinatra, js: express, py: flask, go: gin … Mock Server
  • 57. 57
  • 58. 58
  • 59. 59
  • 60. 60
  • 61. 61
  • 62. 62
  • 63. 63 Key points of implementation
  • 64. ● Mock server ○ crafted using swifter 64 Key points of implementation
  • 65. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket 65 Key points of implementation
  • 66. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket ○ runs on localhost 66 Key points of implementation
  • 67. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket ○ runs on localhost ● Tests ○ do not look at the real backend 67 Key points of implementation
  • 68. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket ○ runs on localhost ● Tests ○ do not look at the real backend ○ independent from each other because the mock server turns on before and turns off after every test 68 Key points of implementation
  • 69. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket ○ runs on localhost ● Tests ○ do not look at the real backend ○ independent from each other because the mock server turns on before and turns off after every test ● We ○ use Launch arguments and Environment variables to redirect the app to the correct server (the mock or production one) 69 Key points of implementation
  • 70. ● Mock server ○ crafted using swifter ○ works with HTTP as well as with Websocket ○ runs on localhost ● Tests ○ do not look at the real backend ○ independent from each other because the mock server turns on before and turns off after every test ● We ○ use Launch arguments and Environment variables to redirect the app to the correct server (the mock or production one) ○ keep golden responses from the backend in the repo and use them as templates, to change/update on the fly during the tests 70 Key points of implementation
  • 71. Challenge Redirect SDK to the mock server 71 Pitfalls
  • 72. Challenge Redirect SDK to the mock server #if … #endif 72 Pitfalls
  • 75. Challenge Redirect SDK to the mock server #if … #endif Share the codebase with SwiftUI 75 Pitfalls
  • 76. Challenge Redirect SDK to the mock server #if … #endif Share the codebase with SwiftUI Swift Package Manager 76 Pitfalls
  • 81. Challenge Redirect SDK to the mock server #if … #endif Share the codebase with SwiftUI Swift Package Manager Sync mock server with the backend 81 Pitfalls
  • 82. Challenge Redirect SDK to the mock server #if … #endif Share the codebase with SwiftUI Swift Package Manager Sync mock server with the backend Stream Chat API 82 Pitfalls
  • 107. ● testableapple.com/native-mock-server-inside-xctest ● github.com/testableapple/mockserver-driven-testing ● github.com/GetStream/stream-chat-swift ● github.com/GetStream/stream-chat-swiftui 107 Useful links