SlideShare a Scribd company logo

Hyper-pragmatic Pure FP testing with distage-testkit

7mind
7mind
7mind7mind

Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale. To tackle this problem we've created distage & distage-testkit, distage-testkit gives you the following superpowers: * ability to easily swap out individual components or entire test environments * principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs * execute effects or allocate resources per-test, e.g. generate random fixtures per-test * first-class testing of functional effects * write tests as lambdas – access test fixtures via parameters or ZIO Environment ...and more! We'll also discuss general testing practices and what really distinguishes good tests from great tests.

Hyper-pragmatic Pure FP testing with distage-testkit

1 of 31
Download to read offline
Hyperpragmatic pure FP testing with distage-testkit
1/31
Hyperpragmatic pure FP testing
with
distage-testkit
Functional Scala 2019
Septimal Mind Ltd
team@7mind.io
1 / 31
Hyperpragmatic pure FP testing with distage-testkit
Tests and Test Taxonomies 2/31
Not all the tests are equal
Tests are important. We know that.
Tests are the simplest way to define and verify important contracts.
And contracts are crucial for project maintainability and viability.
We write tests. A lot of.
But
. . .
some tests prove themselves useful and some do not.
2 / 31
Hyperpragmatic pure FP testing with distage-testkit
Tests and Test Taxonomies 3/31
Not all the tests are equal
Which tests are good and which are bad?
3 / 31
Hyperpragmatic pure FP testing with distage-testkit
Tests and Test Taxonomies 4/31
Bad test criterias
Bad tests are:
◮ Slow,
◮ Unstable: they fail randomly,
◮ Nonviable: they don’t survive refactorings,
◮ Demanding: they require complex preconditions to be met: external services up and
running, fixtures loaded, etc, etc,
◮ Incomprehensible: they signal about a problem but don’t help us to localize the
cause.
4 / 31
Hyperpragmatic pure FP testing with distage-testkit
Tests and Test Taxonomies 5/31
We spend more resources to write and
maintain bad tests
than the value they bring us.
5 / 31
Hyperpragmatic pure FP testing with distage-testkit
Tests and Test Taxonomies 6/31
How may we make our tests better?
6 / 31

Recommended

ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack7mind
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity7mind
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...7mind
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDISven Ruppert
 
Making React Native UI Components with Swift
Making React Native UI Components with SwiftMaking React Native UI Components with Swift
Making React Native UI Components with SwiftRay Deck
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails AppsRabble .
 

More Related Content

What's hot

Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and SpringVMware Tanzu
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
Load Testing with k6 framework
Load Testing with k6 frameworkLoad Testing with k6 framework
Load Testing with k6 frameworkSvetlin Nakov
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Hazem Saleh
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for AndroidHazem Saleh
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
How to setup unit testing in Android Studio
How to setup unit testing in Android StudioHow to setup unit testing in Android Studio
How to setup unit testing in Android Studiotobiaspreuss
 
Unit Test Android Without Going Bald
Unit Test Android Without Going BaldUnit Test Android Without Going Bald
Unit Test Android Without Going BaldDavid Carver
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersITeLearn
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02rhemsolutions
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Grails plugin development
Grails plugin developmentGrails plugin development
Grails plugin developmentMohd Farid
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Codescidept
 
Testing Web Apps with Spring Framework
Testing Web Apps with Spring FrameworkTesting Web Apps with Spring Framework
Testing Web Apps with Spring FrameworkDmytro Chyzhykov
 

What's hot (20)

Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and Spring
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Load Testing with k6 framework
Load Testing with k6 frameworkLoad Testing with k6 framework
Load Testing with k6 framework
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
How to setup unit testing in Android Studio
How to setup unit testing in Android StudioHow to setup unit testing in Android Studio
How to setup unit testing in Android Studio
 
Unit Test Android Without Going Bald
Unit Test Android Without Going BaldUnit Test Android Without Going Bald
Unit Test Android Without Going Bald
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Grails plugin development
Grails plugin developmentGrails plugin development
Grails plugin development
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Testing Web Apps with Spring Framework
Testing Web Apps with Spring FrameworkTesting Web Apps with Spring Framework
Testing Web Apps with Spring Framework
 

Similar to Hyper-pragmatic Pure FP testing with distage-testkit

Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyIRJET Journal
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Ukraine
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarGiel Tettelaar
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
Lessons learned on software testing automation
Lessons learned on software testing automationLessons learned on software testing automation
Lessons learned on software testing automationgaoliang641
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Applitools
 
Software Testing: Test Design and the Project Life Cycle
Software Testing: Test Design and the Project Life CycleSoftware Testing: Test Design and the Project Life Cycle
Software Testing: Test Design and the Project Life CycleDerek Callaway
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsGareth Rushgrove
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksŁukasz Morawski
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxVictor Rentea
 
Google mock training
Google mock trainingGoogle mock training
Google mock trainingThierry Gayet
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox testsKevin Beeman
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG Greg.Helton
 

Similar to Hyper-pragmatic Pure FP testing with distage-testkit (20)

Software Testing
Software TestingSoftware Testing
Software Testing
 
Automating the Quality
Automating the QualityAutomating the Quality
Automating the Quality
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative study
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel Tettelar
 
Combined Project
Combined ProjectCombined Project
Combined Project
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
Lessons learned on software testing automation
Lessons learned on software testing automationLessons learned on software testing automation
Lessons learned on software testing automation
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
 
Software Testing: Test Design and the Project Life Cycle
Software Testing: Test Design and the Project Life CycleSoftware Testing: Test Design and the Project Life Cycle
Software Testing: Test Design and the Project Life Cycle
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG
 

Recently uploaded

The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!ISPMAIndia
 
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTSi-engage
 
AI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriAI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriISPMAIndia
 
P1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetP1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetMatthewTHawley
 
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A..."Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...ISPMAIndia
 
Self scaling Multi cloud nomad workloads
Self scaling Multi cloud nomad workloadsSelf scaling Multi cloud nomad workloads
Self scaling Multi cloud nomad workloadsBram Vogelaar
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkTimothy Spann
 
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이ssuser82c38d
 
Sql server types of joins with example.pptx
Sql server types of joins with example.pptxSql server types of joins with example.pptx
Sql server types of joins with example.pptxsameer gaikwad
 
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ..."Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...ISPMAIndia
 
Manual de la Mezcladora SoundCraft Notepad -12Fx
Manual de la Mezcladora SoundCraft Notepad -12FxManual de la Mezcladora SoundCraft Notepad -12Fx
Manual de la Mezcladora SoundCraft Notepad -12Fxjavierdavidvelasco17
 
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...Oleksandr Zaitsev
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...confluent
 
SPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementSPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementISPMAIndia
 
Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Asher Sterkin
 
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)GDSCNiT
 
Getting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxGetting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxmavinoikein
 
App Builder - Hierarchical Data Apps.pptx
App Builder - Hierarchical Data Apps.pptxApp Builder - Hierarchical Data Apps.pptx
App Builder - Hierarchical Data Apps.pptxPoojitha B
 
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...ISPMAIndia
 

Recently uploaded (20)

The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!
 
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS
100 TOOLS TO MEASURE AND ANALYSE YOUR DIGITAL MARKETING EFFORTS
 
AI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriAI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit Bendigiri
 
Features of IETM Software -Code and Pixels
Features of IETM Software -Code and PixelsFeatures of IETM Software -Code and Pixels
Features of IETM Software -Code and Pixels
 
P1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetP1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 Smartsheet
 
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A..."Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
 
Self scaling Multi cloud nomad workloads
Self scaling Multi cloud nomad workloadsSelf scaling Multi cloud nomad workloads
Self scaling Multi cloud nomad workloads
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
 
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
 
Sql server types of joins with example.pptx
Sql server types of joins with example.pptxSql server types of joins with example.pptx
Sql server types of joins with example.pptx
 
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ..."Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
 
Manual de la Mezcladora SoundCraft Notepad -12Fx
Manual de la Mezcladora SoundCraft Notepad -12FxManual de la Mezcladora SoundCraft Notepad -12Fx
Manual de la Mezcladora SoundCraft Notepad -12Fx
 
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...
Cormas: Modelling for Citizens with Citizens. Building accessible and reliabl...
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
 
SPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementSPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product Management
 
Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024
 
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
 
Getting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxGetting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptx
 
App Builder - Hierarchical Data Apps.pptx
App Builder - Hierarchical Data Apps.pptxApp Builder - Hierarchical Data Apps.pptx
App Builder - Hierarchical Data Apps.pptx
 
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
 

Hyper-pragmatic Pure FP testing with distage-testkit

  • 1. Hyperpragmatic pure FP testing with distage-testkit 1/31 Hyperpragmatic pure FP testing with distage-testkit Functional Scala 2019 Septimal Mind Ltd team@7mind.io 1 / 31
  • 2. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 2/31 Not all the tests are equal Tests are important. We know that. Tests are the simplest way to define and verify important contracts. And contracts are crucial for project maintainability and viability. We write tests. A lot of. But . . . some tests prove themselves useful and some do not. 2 / 31
  • 3. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 3/31 Not all the tests are equal Which tests are good and which are bad? 3 / 31
  • 4. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 4/31 Bad test criterias Bad tests are: ◮ Slow, ◮ Unstable: they fail randomly, ◮ Nonviable: they don’t survive refactorings, ◮ Demanding: they require complex preconditions to be met: external services up and running, fixtures loaded, etc, etc, ◮ Incomprehensible: they signal about a problem but don’t help us to localize the cause. 4 / 31
  • 5. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 5/31 We spend more resources to write and maintain bad tests than the value they bring us. 5 / 31
  • 6. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 6/31 How may we make our tests better? 6 / 31
  • 7. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 7/31 Let’s ditch Unit/Functional/Integration trinity. . . . . . and introduce some new terminology 7 / 31
  • 8. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 8/31 Test Taxonomy: Encapsulation Axis Let’s say that every test falls under one of the following categories: 1. Blackbox tests check just interfaces not knowing anything about implementations behind them, 2. Whitebox tests may know about implementations and check them directly, sometimes even breaking into some internal state to verify if it conforms to test expectations. 8 / 31
  • 9. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 9/31 Test Taxonomy: Isolation Axis Let’s say that every test falls under one of the following categories: ◮ Atomic tests check just one “unsplittable” software component, ◮ Group tests check multiple software components, ◮ Communication tests communicate with outer world (databases, API providers, etc, etc). 9 / 31
  • 10. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 10/31 You may extend and modify this Test Taxonomy as it would be convenient for you. More about test taxonomies: https://blog.7mind.io/constructive-test-taxonomy.html 10 / 31
  • 11. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 11/31 Test Taxonomy: Why So? According to our experience the best tests are Blackbox tests with Atomic or Group Isolation Level. This makes sense: such tests are fast and refactoring-resilient. 11 / 31
  • 12. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 12/31 Communication tests But in real projects most of the tests fall under Communication category (“Integration” tests). Why? 1. Engineers want to test The Whole Thing, 2. It’s hard to separate components, 3. etc, etc. . . 12 / 31
  • 13. Hyperpragmatic pure FP testing with distage-testkit Tests and Test Taxonomies 13/31 Communication tests can be more useful We may replace integration components with Dummies1. This way we may turn Communication tests into Group or Atomic2 1 people also call them “Fakes”, “in-memory implementations” or “Mocks” 2 this statement is valid for Blackbox tests only 13 / 31
  • 14. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 14/31 Dual Test Tactic The same test scenario executed with both Production and Dummy implementations of integration components is beneficial: 1. We can test business logic quickly, without any interference, 2. We still able to verify business logic behaviour with “real” integrations, 3. Dual Test Tactic enforces us to follow LSP and design better. Refactorings are crucial for long-term health of the project. Blackbox tests enable refactorings. Dual Test Tactic drastically reduces the price of refactorings. 14 / 31
  • 15. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 15/31 Dual Test Tactic: ideas 1. Ignore Communication tests in case their dependencies are unsatisfied (service unavailable), don’t fail, 2. Avoid automatic “Mocks”, they prevent encapsulation, 3. Never run heavy dependencies in-process ◮ don’t bring whole Kafka or Cassandra into the classpath. PLEASE 15 / 31
  • 16. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 16/31 Dual Test Tactic: The Main Issue It’s easy to setup test dependencies while working with Dummies But you have to do things differently for Production dependencies. We have to take care of: 1. Resource acquisition and Cleanups, 2. Speed, 3. Memoization and resource reuse, 4. Interference, 5. . . . 16 / 31
  • 17. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 17/31 Dual Test Tactic: dummy repositories testcase make[UserRepo] make[UserService] make[AccountsRepo] make[AccountsService] run[MyTestCase] run[AnotherTestCase] 17 / 31
  • 18. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 18/31 Dual Test Tactic: production repositories testcase Setup Execute Cleanup probe database port make[DbDriver] setup users table setup accounts table make[UserRepo] make[AccountsRepo] remove users table close driver remove accounts table make[UserService] make[AccountsService] run[MyTestCase]run[AnotherTestCase] 1. Order 2. How to avoid unneccessary job? 2.1 Memoize resources?.. 2.2 In a singleton?.. 2.3 When we close resources?.. 2.4 On JVM shutdown?.. Oops, SBT. . . 2.5 Disambiguation (same class, different parameters)?.. 3. Resource deallocation 3.1 . . . even after a failure 3.2 Order! 4. Other integrations, e.g. run Dockers 4.1 . . . and await until they open ports 4.2 . . . and stop them after the tests 5. Configs 18 / 31
  • 19. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 19/31 Dual Test Tactic: Real testcase steps ◮ Integration points stack together ◮ . . . and make the problem notably hard ◮ Manual wiring is hard to maintain ◮ . . . and suffers from combinatoric explosion of possible code paths ◮ Cake pattern doesn’t make much difference ◮ Conventional DI frameworks fail It’s hard to setup variable contexts. 19 / 31
  • 20. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 20/31 Dual Test Tactic may be very pricy under usual circumstances. 20 / 31
  • 21. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 21/31 Can we make it cheap? 21 / 31
  • 22. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 22/31 Yes. 22 / 31
  • 23. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 23/31 The Goal We want to write code like this and never care about setting things up: 1 class JustATest[F[+_, +_]] { 2 "service" must { 3 "do something" in { 4 (users: UserService[F], accounts: AccountingService[F]) => 5 for { 6 user <- users.create() 7 balance <- accounts.getBalance(user) 8 } yield { 9 assert(balance == 0) 10 } 11 } 12 } 13 } 14 15 object JustATestZioProd extends JustATest[zio.IO] with Prod 16 object JustATestZioDummy extends JustATest[zio.IO] with Dummy 23 / 31
  • 24. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 24/31 dist✪ge is a Dependency Injection mechanism for Scala But it lacks negative traits of a typical DI thingy. . . . . . and has many unique properties. . . . and it’s blazing fast. You may call it a module system for Scala. . . . . . with automatic garbage-collecting solver 24 / 31
  • 25. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 25/31 distage 1. Supports FP, wires Resources, Effects, ZIO Environments. . . 2. transparent and predictable ◮ first plan then do ◮ test the outcome without effect execution! ◮ compile-time checks and tests 3. no scala-reflect nor Java reflection1, ◮ ScalaJS support is coming 4. is non-invasive. ◮ You can add it to your project keeping business logic intact. . . ◮ . . . and remove it. 5. is not an ad-hoc thing, it has strong theory behind. 1 Since version 0.10.0, see https://blog.7mind.io/lightweight-reflection.html 25 / 31
  • 26. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 26/31 Docker support in distage While we develop and test we may need our integrations up and running. . . . . . We have docker-compose for that. . . But manual rituals are annoying and Compose is imperfect (wait until service opens port? Hah) Container orchestration is not easy. But. . . We made a distage extension allowing to get rid of Compose in most of the cases. It can run test containers, reuse and shutdown them. And it can await until the service is ready. 26 / 31
  • 27. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 27/31 Let’s look at a real example. . . Source code: https://github.com/7mind/distage-example 27 / 31
  • 28. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 28/31 distage performs optimal ahead of time planning. It doesn’t do any unnecessary job. 28 / 31
  • 29. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 29/31 One More Thing: Roles distage allow you to fuse microservices into “flexible monoliths”. We may: 1. Develop services (Roles) separately, even in a multirepo, 2. Build a single Docker image with multiple Roles in it, 3. Run several Roles within one process ◮ We define roles we want to start as commandline parameters 4. ⇒ higher computation density, savings on infrastructure, 5. ⇒ substantial development simplification ◮ full environment can be started on a low-end machine ◮ with just one command 29 / 31
  • 30. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 30/31 distage-framework is the most productive way to write maintainable pure functional applications with ZIO. (And any other monad) distage-testkit is the best way to make your tests performant and reliable. distage is adopted by several different companies and tested by two years of production usage. 30 / 31
  • 31. Hyperpragmatic pure FP testing with distage-testkit Dual Test Tactic 31/31 Thank you for your attention distage website: https://izumi.7mind.io Septimal Mind is an Irish software consultancy and R&D Company We’re looking for clients, contributors, adopters and colleagues ;) Contact: team@7mind.io Github: https://github.com/7mind Slides: https://github.com/7mind/slides Follow us on Twitter https://twitter.com/shirshovp https://twitter.com/kai_nyasha 31 / 31