API Testing using Python (By Bas Dijkstra)

preview_player
Показать описание
In this STET talk, Bas Dijsktra (Director of International Academy at Inspired Testing), has explained and practically demonstrated API Testing using Python. Check the below agenda for more details:

𝐀𝐠𝐞𝐧𝐝𝐚:

1. Why API Testing?
2. Why Python for API Testing?
3. PyTest Unit Testing Framework
4. Python Requests Library
6. Parameterizing API Tests in Python (Data Driven Testing of APIs)
8. How Beginners have to learn API Testing?
9. Language preference for learning API?
10. Manual Versus Automation of API Testing
11. API Testing Versus UI Testing
12. API Testing and Reporting
13. Other Q&A
Рекомендации по теме
Комментарии
Автор

Premiere chat:

QAFox
​Hi All, Session will begin in few minutes

QAFox
​Bas Dijkstra will be available to answer your questions over chat

Bas Dijkstra
​Hey there everybody! Hope you enjoy watching this session. Feel free to ask any questions here in the chat and I'll be happy to answer them.

QAFox
​Watch this session in full screen and with good quality (Change Youtube quality settings if required)

prasad bhagwat
​HI QAFOX

QAFox
​Welcome Bas Dijkstra

prasad bhagwat
​HI Bas Dijkstra

prasad bhagwat
​Gr8

Anjani Kumar
​Python Request Library and Pytest - are these 2 libraries sufficient for creating a framework for API testing? or we need some other tools too?

prasad bhagwat
​yes

prasad bhagwat
​u can use it

Dmitrii Kilishek
​Hey Bas! Looking forward to the session.

prasad bhagwat
​Yes correct

Bas Dijkstra

Bas Dijkstra
​Hey @Dmitrii Kilishek !

sampath kumar
​Hi Bas Dijkstra.

ichusvideo
​hi

Bas Dijkstra
​Hey all and welcome 🙂

Bas Dijkstra
​(I love how the closed captions showed my name as 'boss the extra')

sampath kumar
​its good bas

Anjani Kumar
​Can you please enlarge the font a little

Liza Jacob
​How is the content type specified here?

Bas Dijkstra
​We'll get to that soon, if you mean asserting on the response content type

Liza Jacob
​Sure, I meant the request content type btw. Is it json by default

Bas Dijkstra
​That's a good question. I'm not sure there's a default, let me quickly look that up

Liza Jacob
​👍

Bas Dijkstra
​If you want to specify it explicitly, it's just a matter of passing a dictionary containing header names and values using the 'header' named argument (more about that later in this session)

Liza Jacob
​Thanks!

Bas Dijkstra
​So when I print the request headers using when I've not explicitly specified any, this is what I see:

Bas Dijkstra
​{'User-Agent': 'python-requests/2.26.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}

Bas Dijkstra
​So no content type header is set by default

Bas Dijkstra
​If you POST data, it's therefore a good idea to explicitly tell the provider what the content type is by adding it as a header

Bas Dijkstra
​Hope that helps!

Liza Jacob
​Yes, it does. Thanks!

sampath kumar
​Das, how can we assert mutliple keys present or not

Bas Dijkstra
​Do you just want to check that multiple elements are present in the response, or also check their value?

sampath kumar
​multiple keys, like validating json schema

Sharon O'Boyle
​If there were a value "name" in the response body would the assert "name" in response_body also pass?

Bas Dijkstra
​Sharon O'Boyle no, the 'in

Bas Dijkstra
​only checks on keys, not values

Sharon O'Boyle
​Great thanks Bas

Bas Dijkstra

Bas Dijkstra
​But I'm sure there's a more efficient way to do that in Python, let me look that up

sampath kumar
​sure Bas.

Liza Jacob
​Would you be covering deserialising with response models?

Bas Dijkstra

Liza Jacob
​OK

Bas Dijkstra
​shows how to check the presence of multiple keys in a dictionary in a single statement

Anuradha Raman
​Bas, will you be showing us parametrisation of data for tests?

Bas Dijkstra

Bas Dijkstra
​That's the final coding example in this session 🙂

Anuradha Raman
​thanks

Amiya Ranjan
​Great session. Can you briefly tell How to handle negative scenarios

Bas Dijkstra

Amiya Ranjan
​For example triggering 400-500 status codes voluntarily and parameterizing in same method

Bas Dijkstra
​Triggering specific responses assumes you have control over how the provider behaves. Since we're working with a public API here, we don't have that control

Amiya Ranjan
​Ok. Thanks 🙂

Bas Dijkstra
​If there is a way you can trigger that response (for example by specific request data or request headers) then it's simply a matter of asserting on that specific response status code

Bas Dijkstra

karun
​Hi QAFOX, Session ended?

sampath kumar
​are we done, AJ?

karun
​Ohh its a break...

Dmitrii Kilishek
​The test is available in the repo 🙂

QAFox
Автор

@Bas Dijkstra, that was a very useful session...cant wait to try this out...Thanks!!

anikasingh
Автор

Hi QAFox,
Can you please answer why should we prefer Pytest for Api Testing?

shafatmasood
Автор

Hi QAFox,
Could you let us know the duration of the talk (API Testing using Python)?
I am in CEST timezone and so wish to plan things accordingly. Thanks

karunakarandhayanidhi
Автор

pytest is not working on intellij and pycharm terminal getting 'pytest' is not recognized as an internal or external command,
however i have installed pytest using command 'pip install pytest==2.9.1'

qafixes
Автор

@QAFox,
Is the API testing session over?

karun
Автор

will it be available to watch again later?recording.

sailajatata
Автор

Hi, what time will it be in GMT (London)?

RealSymphony
join shbcf.ru