Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or...
Transcript of Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or...
![Page 1: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/1.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 2
ConstruatestesefetivosatravésdoprincípioF.I.R.S.T
ElderMoraes|@elderjavaDeveloperAdvocateAbril,2019
![Page 2: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/2.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
SafeHarborStatement
Thefollowingisintendedtooutlineourgeneralproductdirection.Itisintendedforinformationpurposesonly,andmaynotbeincorporatedintoanycontract.Itisnotacommitmenttodeliveranymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions.Thedevelopment,release,timing,andpricingofanyfeaturesorfunctionalitydescribedforOracle’sproductsmaychangeandremainsatthesolediscretionofOracleCorporation.
![Page 3: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/3.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 4
![Page 4: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/4.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 5
FIRST
ASTNDEPENDENTEPEATABLEELF-VALIDATINGIMELY
![Page 5: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/5.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Seostestesforemlentos,vocênãovaiquererexecutá-loscomfrequência
• Sevocênãoosexecutacomfrequência,nãoencontraráproblemascedoosuficienteparacorrigí-losfacilmente
6
FAST
![Page 6: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/6.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
Oquepodefazerumtesteserlento
7
FAST
Execuçãomanual
Validaçãomanual
Aprópriaexecuçãodoteste
![Page 7: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/7.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Eliminandoaexecuçãomanual– Frameworks:JUnit,Arquillian,Selenium,Mockito,Wiremock
– Automações:Maven,Gradle,Jenkins,Vagrant,Ansible,DockerCompose
– Monitoramento:Grafana,Prometheus,Jaeger
8
FAST
![Page 8: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/8.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Eliminandoavalidaçãomanual– VideSELF-VALIDATING
9
FAST
![Page 9: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/9.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Eliminandolentidãonopróprioteste– Identificaçãodospontosdelentidão(bancodedados,integração,rede,etc)– Refatoraçãodecódigo– Mocking
10
FAST
![Page 10: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/10.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Umtestenãodevedependerdooutro
• Umtestenãodevecriarascondiçõesparaopróximoteste
• Vocêdevesercapazdeexecutarcadatesteindividualmenteeexecutartodosostestesemqualquerordem
• Quandoostestesdependeunsdosoutros,oprimeiroafalharcausaumareaçãoemcadeia,dificultandoodiagnósticoeescondendodefeitosquepossamestaradiante
11
I NDEPENDENT
![Page 11: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/11.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Comoeliminardependênciaentretestes– Altacoesão– DRY(Don’tRepeatYourself)
12
I NDEPENDENT
“Wewanttodesigncomponentsthatareself-contained:independent,andwithasingle,well-definedpurpose”
-ThePragmaticProgrammer
![Page 12: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/12.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Comoeliminardependênciaentretestes– Baixoacoplamento
13
I NDEPENDENT
VS
![Page 13: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/13.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 14
![Page 14: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/14.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Testesdeveserreproduzíveisemqualquerambiente
• Produção,QA,laptop(mesmosemrede)
• Docontrário,vocêsempreteráumadesculpaparanãoexecutá-los
• Alémdisso,nãoconseguiráexecutá-losquandooambientenãoestiverdisponível
15
REPEATABLE
![Page 15: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/15.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Eliminandoadependênciadeambientes
16
REPEATABLE
BancodeDados SistemaOperacional DeployeExecução
![Page 16: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/16.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Eliminandoadependênciadeambientes
17
REPEATABLE
![Page 17: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/17.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
Vagrantfile
18
![Page 18: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/18.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Testesdevemserauto-explicativos:passou/falhou• Otestenãodeveexigirque*você*:– Leiaumlog
– Comparedoisarquivos
– Vejaumatela
– Etc…
• Senãoforemauto-explicativos,entãoafalhapodesersubjetiva
• Levaàdemoranavalidação(efalhanoprincípioFAST)
19
SELF-VALIDATING
![Page 19: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/19.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 20
![Page 20: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/20.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 21
![Page 21: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/21.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
• Testesdevemserescritosoquantoantes
• Sevocêesperaumcódigoentraremproduçãoparaescreveroteste,podeacabardescobrindoqueédifíciltestá-lo
• Aofazerissocontinuamente,logovocêterátodoseucódigodeproduçãoimpossíveldesertestado
22
TIMELY
![Page 22: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/22.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
“Testsareasimportant… astheproductioncodeis.Perhapstheyareevenmoreimportant,becausetestspreserveandenhancetheflexibility,maintainability,andreusabilityoftheproductioncode.”
– RoberC.Martin,“CleanCode”
Confidential–OracleInternal/Restricted/HighlyRestricted 23
![Page 23: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/23.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
@elderjavabook.eldermoraes.com
![Page 24: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/24.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.|
Java@CloudAge
bit.ly/javacloudage
![Page 25: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/25.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 26
Visiteonossoestande
Façaumtrial
Ganheumbrinde!
Façaumhandson
Ganheoutrobrinde!
![Page 26: Construa testes efetivos através do princípio F.I.R.S€¦ · Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0ec7fb7e708231d440e810/html5/thumbnails/26.jpg)
Copyright©2019,Oracleand/oritsaffiliates.Allrightsreserved.| 27