Top Banner
I have been building pyramid until I started mining diamonds Jan Koszela
62

I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Jun 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

I have been building pyramid until I started

mining diamonds

Jan Koszela

Page 2: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

Page 3: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

System.out.println(„Hello World!!”);

Page 4: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

System.out.println(„Hello World!!”);

● Jan Koszela● Eclipse Poland Limited at Wrocław● Java Developer / Analyst● 4.5 y. of comm. exp. based on Java web stack, ● automotive, e-commerce● linkedin.com/in/jan-koszela-6bb38583

Page 5: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

Page 6: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

https://twitter.com/pierreyvesrevaz/status/811185305315381248

Page 7: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 8: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 9: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 10: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 11: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 12: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Software testing Pyramid

Page 13: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

3. Integration tests

Page 14: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests

https://onsizzle.com/i/unittests-passing-nointegrationitests-unit-tests-passing-no-integration-tests-53c8003af57f45e4be46960b62cf6627

Page 15: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests

Page 16: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests

http://whisper.sh

Page 17: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests

https://sqa.stackexchange.com/questions/37623/is-inverted-test-pyramid-really-anti-pattern

Page 18: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests

https://sqa.stackexchange.com/questions/37623/is-inverted-test-pyramid-really-anti-pattern

Page 19: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Question 1

Is the inverted test pyramid really anti-pattern?

Page 20: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Answer

https://memegenerator.net/instance/63124251/what-if-i-told-you-matrix-morpheus-what-if-i-told-you-it-depends

Page 21: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

3. Integration tests

4. Ice-cream cone „pattern” cases

Page 22: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Ice-cream cone „pattern” cases

https://i.imgflip.com/1xnwer.jpg

Page 23: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Ice-cream cone „pattern” cases

You are working with legacy code

https://miro.medium.com/max/2625/1*zwjz6gaMniKBhSJC69RjxQ.jpeghttps://images-eu.ssl-images-amazon.com/images/I/518yKmNefUL.jpg

Page 24: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Ice-cream cone „pattern” cases

You have an integration to a specialized physical

device

https://www.paypal.com/us/webapps/mpp/credit-card-reader-how-to/chip-card-readerhttps://www.reichelt.com/de/pl/terminal-kartowy-w-drodze-lub-w-sklepie-sumup-air-p236236.html

Page 25: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Ice-cream cone „pattern” cases

You have an integration to a third party API

https://blog.restcase.com/internal-vs-external-apis/https://dzone.com/articles/an-api-first-development-approach-1

Page 26: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Question 2

https://i.ytimg.com/vi/8SWo2hOcCeA/maxresdefault.jpg

Page 27: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Answer

https://lenorediane.files.wordpress.com/2010/08/no-ice-cream.jpg?w=300&h=300

Page 28: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Question 3

https://www.meme-arsenal.com/en/create/meme/909707

Page 29: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Solution??

Page 30: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Solution??

Page 31: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

;)

https://www.memgenerator.net

Page 32: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

3. Integration tests

4. Ice-cream cone „pattern” cases

5. Diamond test

Page 33: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Diamond test

https://image.slidesharecdn.com/shinebrightlikeadiamond-kyrame-121114195639-phpapp01/95/shine-bright-like-a-diamond-kyrame-1-638.jpg?cb=1352923049

Page 34: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Diamond test

Page 35: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Diamond test● Benefits:

– We have confidence that the code does what it should– Immediate stacktrace feedback thanks to fast-fail

convention– Realistic inputs, expected outputs, we don’t care about

code, because it does what it should– Easier maintenance

Page 36: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Diamond test

● Don't hesitate to adjust the project to your architecture needs● Best case of the pyramid usage, is use it as a guide● In real-world projects more accurately is to use sometimes what we called the DIAMOND TEST● Integration tests as the major part diamond test are still reasonable and relevant for test models

Page 37: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Diamond testYou have an integration

to a third party API

Page 38: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

3. Integration tests

4. Ice-cream cone „pattern” cases

5. Diamond test

6. API first approach

Page 39: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

API first approach

Page 40: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Question 4

What are the benefits of an API-First Approach?

Page 41: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Answer

https://www.slideshare.net/wso2.org/wso2-integration-summit-johannesburg-2019-building-a-successful-api-management-strategy

Page 42: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Question 5

How we are able to defend our microservicefrom external API?

Page 43: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

AnswerTry defensive programming

https://imgflip.com/i/3c1enw

Page 44: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Quiz

JDBC == DbC

???

Page 45: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Indeed x2 :D● JDBC -> JavaDatabase

Connectivity● DbC -> Design by

Contract

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTtfIweKTrQRYo0pwaDDxhqygbSay5m3gEyzBZUXxIxBGmSbcPKwQ&s

Page 46: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

TL;DR1. System.out.println(„Hello World!!”);

2. Software testing pyramid

3. Integration tests

4. Ice-cream cone „pattern” cases

5. Diamond test

6. API first approach

7. Design by Contract

Page 47: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

https://luisespinal.wordpress.com/2012/11/19/design-by-contract-by-example/

Page 48: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

https://github.com/andresteingress/gcontracts/wiki/An-Introduction-to-Programming-by-Contract

Page 49: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Preconditions

Page 50: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Preconditions

Page 51: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Preconditions

Page 52: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Preconditions

https://hashnode.com/post/overly-defensive-programming-hacker-noon-cjdqdozzs037y8rwuh89v8w0m

Page 53: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Postconditions: E2E

Page 54: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Postconditions: Integration tests :)

https://springframework.guru/wp-content/uploads/2018/06/Test_Output-1024x246.png

Page 55: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Design by Contract

Postconditions: Unit Tests

https://on.notist.cloud/slides/deck2561/large-3.jpg

Page 56: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Integration tests:● Not only important from the Diamond Test POV,

but also for Pyramid or Ice-cream cone models● Potentially more effective compared to unit tests,

because we operate on real data. The more data we have, the more resistant application we have got

● Potentially are slower compared to unit tests, but we could improve it, by using in-memory data (quasi integration)

Page 57: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Take aways:● Software test pyramid is a guide for preference

depends on software architecture and client needs. It is not a panacea for everything

● Ice-cream cone anti-pattern still may apply to real use case mostly for legacy code at monolith architecture

● Diamond test model is well suited for microservice-based architecture in real world projects

Page 58: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Take aways:● Building applications based on API-first strategy

allows organizations to develop and maintained efficiently for all devices, platforms a operations systems

● To reduce a risk of failure from integration with third party API try defensive programming

● Contract programming should be used in key areas of our application, like inputs, on which data we depend

● It’s worth writing integration tests because they are based on real data

Page 59: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

●https://sqa.stackexchange.com/questions/37623/is-inverted-test-pyramid-really-anti-pattern

●https://leeorengel.com/software-testing-best-practices/

●https://blog.restcase.com/internal-vs-external-apis/

●https://labs.spotify.com/2018/01/11/testing-of-microservices/

●https://www.slideshare.net/Applitools/visual-regression-testing-at-the-speed-of-unit-testing-by-gil-tayar

●https://swagger.io/resources/articles/adopting-an-api-first-approach/

●https://luisespinal.wordpress.com/2012/11/19/design-by-contract-by-example/

Source of knowledge

Page 60: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Questions?

Page 61: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Feedback

http://bit.do/piramidy_i_diamenty

https://docs.google.com/forms/d/e/1FAIpQLSdZiUukHvMOupvQnjY6_bJgiVeFMjbQ18rgUUxVU3Jh8FGgaQ/viewform

Page 62: I have been building pyramid until I started mining …zielona-gora-jug.github.io/files/IntegrationTests.pdfIntegration tests: Not only important from the Diamond Test POV, but also

Contacthttps://www.facebook.com/jan.koszela

[email protected]

https://www.twitter.com/jan_koszela