março 2016 - como testar sua api rest
TRANSCRIPT
![Page 1: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/1.jpg)
Você testa suas APIs no seu dia a dia? Vamos automatizar estes testes?
FREDERICO MOREIRAwww.fredmoreira.com
![Page 2: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/2.jpg)
INTERNET
DOS
TREM
![Page 3: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/3.jpg)
WHO AM I?var speaker = {
name : 'Frederico Moreira',description : [ 'QA Enginner @Minutrade','Organizador do Minas Testing Conference',
'Fissurado pelo o mundo JS','Entusiasta de Agile Testing','Trabalho com testes desde 2008...','Dj por Hobby','Lutando para crescer o GTS-MG''Não vivo sem uma boa cerveja, pinga e queijo ;)'],blog : 'fredmoreira.com'};
![Page 4: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/4.jpg)
console.log('MINUTRADE');
![Page 5: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/5.jpg)
API é um conjunto de rotinas e padrões de programação para acesso a um aplicativo de software ou plataforma baseado na Web.
Fonte: http://canaltech.com.br/o-que-e/software/o-que-e-api/
Uma API é criada quando uma empresa de software tem a intenção de que outros criadores de software desenvolvam produtos associados ao seu serviço.
O que é ?
![Page 6: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/6.jpg)
![Page 7: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/7.jpg)
Testes no nível de serviçosPreenche o gap entres os testes de unidade e os testes de UIComum em times ágeis, dependendo da arquitetura.Acontecem em paralelo ao desenvolvimentoFoco na funcionalidade, não no comportamento ou experiência do clienteSubcutaneous Tests (MartinFowler)
![Page 8: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/8.jpg)
Fonte: http://goo.gl/p98Muv
![Page 9: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/9.jpg)
![Page 10: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/10.jpg)
![Page 11: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/11.jpg)
![Page 12: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/12.jpg)
Fonte: https://www.deepcrawl.com/knowledge/guides/the-abc-of-http-status-codes/
![Page 13: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/13.jpg)
Fonte: http://httpstatusdogs.com/
![Page 14: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/14.jpg)
Fonte: http://httpstatusdogs.com/
![Page 15: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/15.jpg)
Fonte: http://httpstatusdogs.com/
![Page 16: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/16.jpg)
Fonte: https://http.cat/
![Page 17: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/17.jpg)
Fonte: https://http.cat/
![Page 18: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/18.jpg)
Fonte: https://http.cat/
![Page 19: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/19.jpg)
Resultados esperados
Valor
Tipo de dado
Consistência
Erros
![Page 20: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/20.jpg)
Como testar manualmente ?
![Page 21: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/21.jpg)
Ferramentas
![Page 22: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/22.jpg)
![Page 23: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/23.jpg)
Entendendo transações HTTP
![Page 24: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/24.jpg)
#COMANDO CURL
curl -i -X GET "http://localhost:5000/contacts?name=Tester"
#HEARDER
HTTP/1.1 200 OKX-Powered-By: ExpressContent-Type: application/json; charset=utf-8Content-Length: 110ETag: W/"6e-Za+ESrkoytVXhydy0NJoFA"Date: Mon, 14 Mar 2016 18:17:19 GMTConnection: keep-alive
#BODY
[{"_id":"56d5efa8c82593800291c02b","name":"Tester","mobilephone":"0552188889999","homephone":"0552133332222"}]
![Page 25: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/25.jpg)
Postman
![Page 26: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/26.jpg)
Postman
![Page 27: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/27.jpg)
Mas eu preciso mesmo automatizar testes de API ?
![Page 28: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/28.jpg)
![Page 29: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/29.jpg)
![Page 30: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/30.jpg)
Mundo JS
http://www.fredmoreira.com/2014/11/como-voce-anda-testando-sua-api-rest.html
http://goo.gl/Ft6xZJ
http://dareid.github.io/chakram/
![Page 31: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/31.jpg)
Mundo Ruby
![Page 32: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/32.jpg)
Mundo Java
https://www.youtube.com/watch?v=dShI6n1CSoY
@juliodelimas
![Page 33: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/33.jpg)
![Page 34: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/34.jpg)
Testes de segurança
![Page 35: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/35.jpg)
Se eu não quiser rodar nenhuma api na minha máquina?
![Page 36: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/36.jpg)
http://www.mocky.io/
![Page 37: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/37.jpg)
Repositório GitHubhttps://github.com/fredmoreira/phone-book
![Page 38: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/38.jpg)
![Page 39: Março 2016 - Como testar sua API Rest](https://reader035.vdocuments.mx/reader035/viewer/2022062223/58832adc1a28abe2758b7513/html5/thumbnails/39.jpg)
Links
http://katrinatester.blogspot.com.br/2015/09/api-web-services-microservices-testing.html
http://www.guru99.com/api-testing.html
http://www.restpatterns.org/
http://www.tutorialspoint.com/software_testing_dictionary/api_testing.htm
https://www.hurl.it/