SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
Testing Practicies not
only in Scala
by Paweł Panasewicz
pawel.panasewicz(at)gmail.com
@pawelpanasewicz
github.com/PawelPanasewicz
... actually ...
ScaLAB Conference, 2016 Wrocław
1
Who am I
Professionally for > 10 years in Software Development
mostly in commercial projects
Impressed by Scala Language and Functional Approach
In free time
engaged in Music Production
learning about Artificial Intelligence
like to ride bicycle
2
Prologue
3
The Analyst
val analyst = //there was an analyst
Analyst(whatLearnt = Set()) //at the beginning he knew not a lot
.copy(whatLearnt = Set(UML, SQL, XML)) //but in time he's achieved skills
analyst
.changeYear(_ + 5) //... few years later
.`are my skills still up to date` //?
//👍 All Skills Up To Date
4
The Project Manager
val manager = //there was a project manager
ProjectManager(whatLearnt = Set()) //at the beginning he knew not a lot
.copy(whatLearnt = Set(GantChart,
ManagingStyles.visionary, WritingSolemnEmails,
ManagingStyles.commanding)
) //but in time he's achieved skills
manager
.changeYear(_ + 5) //... few years later
.`are my skills still up to date` //?
//👍 All Skills Up To Date
5
The Software Developer
val developer = //there was a software developer
Developer(whatLearnt = Set()) //at the beginning he knew not a lot
.copy(whatLearnt = Set(
Slick1, Slick2, Spray1, Angular1, play1,
`play < 2.5`, `your favourite example of not to old tech`
)) //intelligent beast has learnt a lot
developer
.changeYear(_ + 5) //... few years later
.`are my skills still up to date` //?
// 😕 Well Not Really
6
So what?
The best-before date of IT technologies are often short space of
time
As good Software Developer you have to frequently update your
skills
It would be nice if there were some areas which don't change so
rapidly
because you could successfully take advantages of them for long
time
Well, there are such areas and among them:
Design Patterns
Software Development Philosophies
Shortcuts in Intellij and Vim
Testing 😎
7
Agenda
Why to test code?
What code testing is all about?
Good practicies
8
in order to deliver high quality sofware and be safe
Why
In general
to test code?
9
Why
In particular
to test code?
to demonstrate that the software satisfies its
specification
to find bugs during development phase, not
during production run
to be safe when refactoring - tests will notify me
when introducing regression errors
10
I want to show the estimation of work done - there is as much progress as many test
scenarios in code base
I want to document how my codes and whole system works - it's helpfull not only for
other devs but as well managers, analysts and users.
TDD techniques guide mu during development
ATDD techniques make sure system does what business/users/analysts needs
I want to report performance of my application
I want to repair system because of the bug on production - first I develop the failing
test which reprodces the error, next I can fix it
I am just a prone to make mistakes human
many other factors inlcuding ~120 Mega results from google.com:
https://www.google.com/?gfe_rd=cr&gws_rd=cr&fg=1#q=why+to+test+software
In particular
Why
to test code?
11
What
is code testing all about?
In particular
12
Piece of code
Piece of code
consists of / forms
0..n
1
definition
13
Unit & Integration tests
what are?
code code code code code ... code code code code code
these kind of codes are tested by
integration tests
these kind of codes are tested
by unit tests
one big
integrated
code
perfect
undivided
unit of code
E2E, System Tests
Acceptance, Functional, UI
API Tests
Component,
Isolated UI,
Just Unit Test
- tests are performed when application is deployed on environment
- tests are performed during builds and development
14
they test if many components
cooperate well together
by developers not only to
developers
slower
they test behaviour of relative
small pieces of code in
isolation
by developers to developers
easy to test many scenarios
and hunt a bug
fast
mocking
Acceptance/Functinal testsUnit tests
Unit vs Functional
tests
15
ensure that app works
according to business
requirements (whatever the
implementation is)
do assure that developer's
design is in accordance with
business requirements
functionality guards
more parts together then less
worries
ensure that piece of code
works according to developer's
design
do not assure that developer's
design is in accordance with
business requirements
it's often silently assumed that
mocked dependecies will
behave in particular way which
is dangerous 'cuz unit tests will
not cover that
when designing new functionality
Unit vs Functional
Acceptance/Functinal testsUnit tests
16
Plan of attack
when delivering new functionality
1. Start from basic acceptance tests
2. Keep on refactoring
3. When requirements and architecture stops evolving hunt for
bugs using extensive Unit Tests
17
Good Practicies
advices when testing
18
Develop Calendar Service
CS must decide if particular day is
a working day or a holiday
API exposed in rest-like form
The Calendar Service
Example
BTW There are two
devs delegeted to
this task
19
Let's assume that we are using , and somehow there are imported testing goodies like HttpClient and nextFreePort() ...ScalaTest
First
small happy path acceptance scenario
20
Test Run
failed red
21
Implementation
as simple as needed
keybord is swapped and second developer is making
implementation whereas the first one is observing
(no slide with code with correct implementation, sorry
for that)
22
green
Test re-run
once again
great success !
23
Mondays are working days
more happy paths
keybord is swapped, the second dev is observing now
new testcases (still happy paths) are made
24
red
Test re-run
once again
25
Implementation
without extra features
keybord is swapped and second developer is making
implementation whereas the first one is observing
(no slide with code with correct implementation, sorry
for that)
26
red
Test re-run
and regression error found
ooopps, something went wrong ...
REGRESSION ERROR introduced
Tests are for rescue 😎
27
Implementation
and debugging
keybord is swapped and second developer is making
implementation whereas the first one is observing
28
red
Test re-run
all green
29
Refactoring
optimise readability, make it beautiful
"table of
contents"
private guts
in
descendent
order of
importance
30
red
Test re-run
all green
31
Quiz
Which "design patterns" have you noticed here?
Make it testable - the most important
TDD (or even ATDD or BDD)
Red Green Refactor
Happy Path first
Important goes up
Pair Programming
Baby steps
almost like a "pure function"
KISS
32
The Calendar Service
new requirements
different clients of CS have
different working days
default functionality must be
preserved
33
Meet the Table
and put test cases in such form
easy to create new test cases
easy to read
34
"Table of contents"
still in front of spec
and test routine may look like this:
35
Quiz
Which new "design patterns" have you noticed
here?
Table Driven Testing
36
The Calendar Service
new requirements
it must be documented
documentation must be
always up to date
37
Documenting
the functionality
38
Under the hood
it's just simple HTML
extra html attributes
part of resources
39
Executing Spec
is performed during tests
Html document can be parsed
Extra HTML attribues can help in that
Extracted values can be seen as:
and can be used to generate many testcases
which can be used for testing
40
Spec output
after test run
green - tests succeded
red - tests failed
41
Quiz
Which new "design patterns" have you noticed
here?
Executable Spec (Living Documentation)
42
Living Documentation
closer look at
Engage [developers] with your users
Create a shared domain language
Build mutually-understood delivery contracts
Describe the system concisely, so that errors and redundancy are
easily visible
Write living documentation: always coupled to the actual behaviour
of the system
- Chris Agmen Smith - autor of Petswood
- scala framework for it
- Free ebook
Petswood
Living doumentation
43
The Calendar Service
new requirements
web page
44
Project of web page
functionality
Choose system, provide date string, click submit. There
should appear message "working day" or "holiday" in
gray area. (sorry for typos)
45
Test routine
could look like this
it's ugly, unreadable
46
Abstract
over it
create high level API for manipulating the page
API can contain assertions (checkThatContains)
API can be reused
nicely explains what the test does
47
Quiz
Which design pattern have you noticed here?
Window Driver
48
Other techniques
handy when testing
49
Bob Snaphot's
technique
record input and output and use this data for testing
if actual output during tests differs from recorded that means
that regression errors were introduced
save output to files when test run and use diff tool for fast spot
differences
use it
when you don't really know what right behaviour/ouptut
should be
only subject expert matter can decide if behaviour is fine
when you render something
50
More test code lines
then production code lines
It's good sign
measure it
51
howitworks
package
use it as playground when learning something new which might
be used in project
easy to copy/paste working solution
easy to remove when not needed or disturbing
often better then stackoverflow
52
Domain Test Data in one place
good practice
test data builders and factories
example data in one place
even identifiers of rows id DB and their values
understanding domain data is key to understand what system is
supposed to do
53
That's it
Thank you!
Questions?
54

Weitere ähnliche Inhalte

Was ist angesagt?

Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Mohamed Taman
 
Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and phpTho Q Luong Luong
 
Test driven development
Test driven developmentTest driven development
Test driven developmentHarry Potter
 
Qa mockup interview for automation testing
Qa mockup interview for automation testingQa mockup interview for automation testing
Qa mockup interview for automation testingKadharBashaJ
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
 
Test Automation Strategies For Agile
Test Automation Strategies For AgileTest Automation Strategies For Agile
Test Automation Strategies For AgileNaresh Jain
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
Creating Maintainable Automated Acceptance Tests
Creating Maintainable Automated Acceptance TestsCreating Maintainable Automated Acceptance Tests
Creating Maintainable Automated Acceptance TestsJez Humble
 
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...TechTalks
 
Istqb intro with question answer for exam preparation
Istqb intro with question answer for exam preparationIstqb intro with question answer for exam preparation
Istqb intro with question answer for exam preparationKevalkumar Shah
 
Integrate Test Activities in Agile
Integrate Test Activities in AgileIntegrate Test Activities in Agile
Integrate Test Activities in AgileTEST Huddle
 

Was ist angesagt? (15)

Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and php
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Qa mockup interview for automation testing
Qa mockup interview for automation testingQa mockup interview for automation testing
Qa mockup interview for automation testing
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
 
Test Automation Strategies For Agile
Test Automation Strategies For AgileTest Automation Strategies For Agile
Test Automation Strategies For Agile
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Google test training
Google test trainingGoogle test training
Google test training
 
Creating Maintainable Automated Acceptance Tests
Creating Maintainable Automated Acceptance TestsCreating Maintainable Automated Acceptance Tests
Creating Maintainable Automated Acceptance Tests
 
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
 
Manual testing ppt
Manual testing pptManual testing ppt
Manual testing ppt
 
Istqb intro with question answer for exam preparation
Istqb intro with question answer for exam preparationIstqb intro with question answer for exam preparation
Istqb intro with question answer for exam preparation
 
Integrate Test Activities in Agile
Integrate Test Activities in AgileIntegrate Test Activities in Agile
Integrate Test Activities in Agile
 

Ähnlich wie Testing practicies not only in scala

Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure rupeshchanchal
 
Building Scalable Development Environments
Building Scalable Development EnvironmentsBuilding Scalable Development Environments
Building Scalable Development EnvironmentsShahar Evron
 
PVS-Studio confesses its love for Linux
PVS-Studio confesses its love for LinuxPVS-Studio confesses its love for Linux
PVS-Studio confesses its love for LinuxPVS-Studio
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ SpotifyAndrii Dzynia
 
IIBA and Solvera May Event - Testing w Agile slides
IIBA and Solvera May Event - Testing w Agile slidesIIBA and Solvera May Event - Testing w Agile slides
IIBA and Solvera May Event - Testing w Agile slidesSaskatchewanIIBA
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Dinis Cruz
 
Software presentation
Software presentationSoftware presentation
Software presentationJennaPrengle
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...mCloud
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentZendCon
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanQA or the Highway
 
Chapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxChapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxketurahhazelhurst
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practicesSkills Matter
 
Continuous Intelligence Workshop
Continuous Intelligence WorkshopContinuous Intelligence Workshop
Continuous Intelligence WorkshopDavid Tan
 
manual-testing
manual-testingmanual-testing
manual-testingKanak Mane
 

Ähnlich wie Testing practicies not only in scala (20)

Tdd
TddTdd
Tdd
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Building Scalable Development Environments
Building Scalable Development EnvironmentsBuilding Scalable Development Environments
Building Scalable Development Environments
 
DevOps
DevOpsDevOps
DevOps
 
PVS-Studio confesses its love for Linux
PVS-Studio confesses its love for LinuxPVS-Studio confesses its love for Linux
PVS-Studio confesses its love for Linux
 
Quality Software Development
Quality Software DevelopmentQuality Software Development
Quality Software Development
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ Spotify
 
IIBA and Solvera May Event - Testing w Agile slides
IIBA and Solvera May Event - Testing w Agile slidesIIBA and Solvera May Event - Testing w Agile slides
IIBA and Solvera May Event - Testing w Agile slides
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
 
Software presentation
Software presentationSoftware presentation
Software presentation
 
Code Review
Code ReviewCode Review
Code Review
 
Write tests, please
Write tests, pleaseWrite tests, please
Write tests, please
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
Chapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxChapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docx
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practices
 
Continuous Intelligence Workshop
Continuous Intelligence WorkshopContinuous Intelligence Workshop
Continuous Intelligence Workshop
 
manual-testing
manual-testingmanual-testing
manual-testing
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Testing practicies not only in scala

  • 1. Testing Practicies not only in Scala by Paweł Panasewicz pawel.panasewicz(at)gmail.com @pawelpanasewicz github.com/PawelPanasewicz ... actually ... ScaLAB Conference, 2016 Wrocław 1
  • 2. Who am I Professionally for > 10 years in Software Development mostly in commercial projects Impressed by Scala Language and Functional Approach In free time engaged in Music Production learning about Artificial Intelligence like to ride bicycle 2
  • 4. The Analyst val analyst = //there was an analyst Analyst(whatLearnt = Set()) //at the beginning he knew not a lot .copy(whatLearnt = Set(UML, SQL, XML)) //but in time he's achieved skills analyst .changeYear(_ + 5) //... few years later .`are my skills still up to date` //? //👍 All Skills Up To Date 4
  • 5. The Project Manager val manager = //there was a project manager ProjectManager(whatLearnt = Set()) //at the beginning he knew not a lot .copy(whatLearnt = Set(GantChart, ManagingStyles.visionary, WritingSolemnEmails, ManagingStyles.commanding) ) //but in time he's achieved skills manager .changeYear(_ + 5) //... few years later .`are my skills still up to date` //? //👍 All Skills Up To Date 5
  • 6. The Software Developer val developer = //there was a software developer Developer(whatLearnt = Set()) //at the beginning he knew not a lot .copy(whatLearnt = Set( Slick1, Slick2, Spray1, Angular1, play1, `play < 2.5`, `your favourite example of not to old tech` )) //intelligent beast has learnt a lot developer .changeYear(_ + 5) //... few years later .`are my skills still up to date` //? // 😕 Well Not Really 6
  • 7. So what? The best-before date of IT technologies are often short space of time As good Software Developer you have to frequently update your skills It would be nice if there were some areas which don't change so rapidly because you could successfully take advantages of them for long time Well, there are such areas and among them: Design Patterns Software Development Philosophies Shortcuts in Intellij and Vim Testing 😎 7
  • 8. Agenda Why to test code? What code testing is all about? Good practicies 8
  • 9. in order to deliver high quality sofware and be safe Why In general to test code? 9
  • 10. Why In particular to test code? to demonstrate that the software satisfies its specification to find bugs during development phase, not during production run to be safe when refactoring - tests will notify me when introducing regression errors 10
  • 11. I want to show the estimation of work done - there is as much progress as many test scenarios in code base I want to document how my codes and whole system works - it's helpfull not only for other devs but as well managers, analysts and users. TDD techniques guide mu during development ATDD techniques make sure system does what business/users/analysts needs I want to report performance of my application I want to repair system because of the bug on production - first I develop the failing test which reprodces the error, next I can fix it I am just a prone to make mistakes human many other factors inlcuding ~120 Mega results from google.com: https://www.google.com/?gfe_rd=cr&gws_rd=cr&fg=1#q=why+to+test+software In particular Why to test code? 11
  • 12. What is code testing all about? In particular 12
  • 13. Piece of code Piece of code consists of / forms 0..n 1 definition 13
  • 14. Unit & Integration tests what are? code code code code code ... code code code code code these kind of codes are tested by integration tests these kind of codes are tested by unit tests one big integrated code perfect undivided unit of code E2E, System Tests Acceptance, Functional, UI API Tests Component, Isolated UI, Just Unit Test - tests are performed when application is deployed on environment - tests are performed during builds and development 14
  • 15. they test if many components cooperate well together by developers not only to developers slower they test behaviour of relative small pieces of code in isolation by developers to developers easy to test many scenarios and hunt a bug fast mocking Acceptance/Functinal testsUnit tests Unit vs Functional tests 15
  • 16. ensure that app works according to business requirements (whatever the implementation is) do assure that developer's design is in accordance with business requirements functionality guards more parts together then less worries ensure that piece of code works according to developer's design do not assure that developer's design is in accordance with business requirements it's often silently assumed that mocked dependecies will behave in particular way which is dangerous 'cuz unit tests will not cover that when designing new functionality Unit vs Functional Acceptance/Functinal testsUnit tests 16
  • 17. Plan of attack when delivering new functionality 1. Start from basic acceptance tests 2. Keep on refactoring 3. When requirements and architecture stops evolving hunt for bugs using extensive Unit Tests 17
  • 19. Develop Calendar Service CS must decide if particular day is a working day or a holiday API exposed in rest-like form The Calendar Service Example BTW There are two devs delegeted to this task 19
  • 20. Let's assume that we are using , and somehow there are imported testing goodies like HttpClient and nextFreePort() ...ScalaTest First small happy path acceptance scenario 20
  • 22. Implementation as simple as needed keybord is swapped and second developer is making implementation whereas the first one is observing (no slide with code with correct implementation, sorry for that) 22
  • 24. Mondays are working days more happy paths keybord is swapped, the second dev is observing now new testcases (still happy paths) are made 24
  • 26. Implementation without extra features keybord is swapped and second developer is making implementation whereas the first one is observing (no slide with code with correct implementation, sorry for that) 26
  • 27. red Test re-run and regression error found ooopps, something went wrong ... REGRESSION ERROR introduced Tests are for rescue 😎 27
  • 28. Implementation and debugging keybord is swapped and second developer is making implementation whereas the first one is observing 28
  • 30. Refactoring optimise readability, make it beautiful "table of contents" private guts in descendent order of importance 30
  • 32. Quiz Which "design patterns" have you noticed here? Make it testable - the most important TDD (or even ATDD or BDD) Red Green Refactor Happy Path first Important goes up Pair Programming Baby steps almost like a "pure function" KISS 32
  • 33. The Calendar Service new requirements different clients of CS have different working days default functionality must be preserved 33
  • 34. Meet the Table and put test cases in such form easy to create new test cases easy to read 34
  • 35. "Table of contents" still in front of spec and test routine may look like this: 35
  • 36. Quiz Which new "design patterns" have you noticed here? Table Driven Testing 36
  • 37. The Calendar Service new requirements it must be documented documentation must be always up to date 37
  • 39. Under the hood it's just simple HTML extra html attributes part of resources 39
  • 40. Executing Spec is performed during tests Html document can be parsed Extra HTML attribues can help in that Extracted values can be seen as: and can be used to generate many testcases which can be used for testing 40
  • 41. Spec output after test run green - tests succeded red - tests failed 41
  • 42. Quiz Which new "design patterns" have you noticed here? Executable Spec (Living Documentation) 42
  • 43. Living Documentation closer look at Engage [developers] with your users Create a shared domain language Build mutually-understood delivery contracts Describe the system concisely, so that errors and redundancy are easily visible Write living documentation: always coupled to the actual behaviour of the system - Chris Agmen Smith - autor of Petswood - scala framework for it - Free ebook Petswood Living doumentation 43
  • 44. The Calendar Service new requirements web page 44
  • 45. Project of web page functionality Choose system, provide date string, click submit. There should appear message "working day" or "holiday" in gray area. (sorry for typos) 45
  • 46. Test routine could look like this it's ugly, unreadable 46
  • 47. Abstract over it create high level API for manipulating the page API can contain assertions (checkThatContains) API can be reused nicely explains what the test does 47
  • 48. Quiz Which design pattern have you noticed here? Window Driver 48
  • 50. Bob Snaphot's technique record input and output and use this data for testing if actual output during tests differs from recorded that means that regression errors were introduced save output to files when test run and use diff tool for fast spot differences use it when you don't really know what right behaviour/ouptut should be only subject expert matter can decide if behaviour is fine when you render something 50
  • 51. More test code lines then production code lines It's good sign measure it 51
  • 52. howitworks package use it as playground when learning something new which might be used in project easy to copy/paste working solution easy to remove when not needed or disturbing often better then stackoverflow 52
  • 53. Domain Test Data in one place good practice test data builders and factories example data in one place even identifiers of rows id DB and their values understanding domain data is key to understand what system is supposed to do 53