Become a Creator today!Start creating today - Share your story with the world!
Start for free
00:00:00
00:00:01
Graphql Contract Testing with Rafaela Azevedo image

Graphql Contract Testing with Rafaela Azevedo

S2 E2 ยท How to start API Contract Testing series
Avatar
288 Plays2 years ago

In this episode we talk about contract testing with graphql and web3. Rafeala is the course author of Contract Testing with Pact on Test Automation University and CEO/Co-Founder at TheChainAcademy. Hope you enjoy the episode. Rafaela Azevedo has a great blog on graphql with contract testing. Why not join her Web3 Tests Community.

Transcript

Introduction to Raffaella and Contract Testing

00:00:00
Speaker
A couple of weeks ago, I had a great conversation with Raffaella. Raffaella is the course author of Contract Testing with PACT on Test Automation University. In this episode, we talk about contract testing with GraphQL and we touch on web3. Hope you enjoy the episode. Hey, Raffaella, nice to have you on the podcast.

Raffaella's Journey in QA

00:00:25
Speaker
Can you give us a little intro about yourself, your company, and what you're up to at the moment? Yeah, sure. Thanks for inviting me, Lewis. We finally met, as I said before.
00:00:39
Speaker
And you know, every time that we are in this QA community, we are always like seeing each other, but it's hard to actually take some time to talk to people, which is a shame, but finally. So yeah, just a bit about me. Basically, I'm Brazilian. I moved to London 10 years ago now, and I have been working with QA
00:01:06
Speaker
since 2008. So I think it's maybe 15 years, 16 around that time. So I jumped at a lot in different type of tests and even did a bit of develop. So depending on the project,
00:01:24
Speaker
I need to adapt and learn new things, which is good. But I'm mostly definitely in QA test automation and everything around that. And I have been working as a QA consultant now for maybe four or five years, which is a bit different because then you jump even more from one project to another.
00:01:53
Speaker
It's really good because you have a lot of exposure and you learn different things all the time and refresh your mind. But yeah, yeah, I have been well, to be honest, I think this is this is I finally found like my place as you know, as a consultant, because of this changing projects.
00:02:14
Speaker
Awesome yeah

Web3 Enthusiasm and Community Building

00:02:15
Speaker
yeah I think the variety definitely keeps things fresh and keeps you on your toes and yeah you're kind of doing stuff around web 3 and things like that at the moment so yeah tell us a bit about that. Yeah so because you know I have been working as a consultant we usually we are working in projects that okay it's something that you have done before or something that you are learning
00:02:44
Speaker
But then you always like want to learn something else. And I do this quite a lot as well. And yeah, now I'm learning a lot about Webtree. It's been a while already. It's to be honest, I can even compare with contracts tests when they start to do and actually contracting testing was something that kind of. Helped me a law with Webtree smart contracts because they are quite
00:03:11
Speaker
similar, you know, the idea, the concept, I think. And yeah, and then I have been working with WebTree trying to, so we create this WebTree test community now. It's on Discord, but we don't have too many people yet. But I have talked to some other experts in the area and I'm trying to
00:03:33
Speaker
get more people because you know it's quite small and now everybody's talking about AI not work anymore so basically i'm trying to get more people but it's a bit hard but yeah i'm learning as well which is always good anyway something nice yeah

Contract Testing vs. Web3 Smart Contracts

00:03:57
Speaker
Yeah. And so what do you think kind of the similarities are in the kind of web tree testing and testing you've done before in the contract? Basically, you know, the part of the agreement that you need to you need to have like for web tree and blockchain is like proof of concepts and you need to have the agreement. So, you know, before contract tests, I had no idea these kind of things.
00:04:25
Speaker
even though with API is a bit different because of this proof of concept and these contracts that you need to agree from consumer and provider kind of was quite related to the web tree and smart contracts as well. Of course, they have their own particularities. General idea, the concept is the same.
00:04:48
Speaker
I think that really makes sense. Cause for me, that was one of the hardest things to get my head around was kind of like, yeah, how do you establish these conversations? Yeah. Yeah. That was a big, yeah, that was a big thing for me when I was learning about the contract tests. I remember that was like, you know, that gift, you know, the guy that was blowing the mind and everything and then, Oh my God. Yeah. I don't need to, you know, do the API tests anymore because.
00:05:16
Speaker
know was you don't need to rely on the internet and all these things that were quite flaky and was you know was impacting a lot the result of the test of course and then also you know the maintenance because with contract tests basically they generate the contract itself so yeah it was like mind-blowing for me yeah definitely hot topic obviously is is around trying to
00:05:45
Speaker
scale our tests and trying to make them more stable and everything like that. So I think that really helps with that. Yeah, definitely. Yeah. This

GraphQL Project Experience

00:05:56
Speaker
is actually one of the differentials of, you know, contract testing in API.
00:06:01
Speaker
And I was really lucky when I was doing, because I kind of pushed contract tasks when I was, you know, in this job, because it was a greenfield project. And then I thought I could, you know, try to influence the developers there.
00:06:20
Speaker
And they were all on board and they were also like amazed when they start to show the things. And we were, it was a really good interaction because we were both like super excited about, oh my God, oh my God, we don't have, we don't need to do that. I can't believe that we are not, you know, doing the, you know, we are not relying on the internet or anything like that. We don't have speed performance problems. So yeah. And it was trustworthy, isn't it?
00:06:47
Speaker
because sometimes you think, oh, it's just a mock. So, oh, we can trust for sure and updating and everything, but, you know, contract tests, it's just like, it's stress-worthy as much as the API tests. Yeah, definitely. And it's rare to get the kind of excitement for testing. So that's really cool environment to be in.
00:07:13
Speaker
Yeah and so obviously you kind of have experience with the kind of GraphQL side of APIs as well. I know it was quite a while back when you wrote the article. Hopefully we can jog your memory and chat about that a little bit. So

React Native and GraphQL Testing Challenges

00:07:31
Speaker
yeah what was the project that you were working on where you were using GraphQL
00:07:35
Speaker
Yeah, so I remember I was a contractor already and it was this greenfield project. So we were starting everything from scratch. And to be honest, the team was quite small. That's why, and because it was a greenfield project, it was such a nice experience. I remember because I had the autonomy to choose everything like test strategy,
00:08:04
Speaker
And these from the beginning makes such a difference because, you know, the guys they are choosing the framework, they are going to develop everything from scratch, from the development side and business. And also the testing side is also like, you know, going at the same pace, which makes, you know, a difference when you want to deliver fast and everything and everything is accurate and has, have a good strategy.
00:08:33
Speaker
And then, yeah, I remember that was a React native project and we had to do some tests on the mobile app as well. So that was like browser and mobile. And I was trying to use everything new and the contact test was really new for me. And then I thought, okay, so for, you know, for the,
00:09:01
Speaker
kind of API tests, we can use contract tests and see how it goes. And then for the functional tests, I was using a tool called detox. I remember it was really, really in the beginning. So there was almost no support. I don't know now how it is, to be honest, I'm going to confess, even, you know, because I have been working with observability
00:09:26
Speaker
and monitoring, Kibana, AWS, EC2, all these things now. So I'm a bit like far from, from these tools nowadays. But yeah, I remember that EvenPacti was still in the beginning, but was super exciting too.
00:09:45
Speaker
to test everything and see how it goes and create the test strategy. And the good thing as well was, you know, the team was really good. The developers, they were also learning with me and was really, really good atmosphere and the experience. Everybody was on board to try these new things and see how it goes.

GraphQL vs. Traditional API Testing

00:10:10
Speaker
And I remember because usually, you know,
00:10:13
Speaker
sometimes I have problems when setting up. I don't know if I'm the only one, but every time I'm doing a setup, I always sweat. Oh my God, this is always a nightmare, especially when you're doing the beginning of the person and then you don't do it for ages. Even when it's a tool that you know already. This one was completely new and I was already, oh my God, this is a nightmare.
00:10:43
Speaker
But you know it was actually quite fine compared to I don't know first time that I set up Selenium with John. So it was much better but I remember that you know the developers they were really keen to
00:11:00
Speaker
help and find the solutions. Especially with GraphQL because I remember as well there was a particular thing that I had to do with the data. It was a function, I don't know if they have very integration now, but I remember to get the data and compare and do the verification in the end. I remember that I had to do some special thing,
00:11:28
Speaker
function that I had to use and I took ages to find. Yeah, I can imagine because I haven't really worked with GraphQL too much. But yeah, apart from a side project where I was doing a mobile app as well. But yeah, I think the kind of provider state where you've got the middleware and stuff like that, that would be quite difficult to configure in GraphQL. But yeah, I guess what I kind of the other differences that you noticed between
00:11:56
Speaker
API and GraphQL, if any, when doing contract testing. To be honest, I really like it to work with GraphQL.
00:12:06
Speaker
You said that you work more with API, right? And you didn't work with GraphQL much too much. In terms of contract testing, for me, it was the opposite. I worked just with GraphQL and not too much with API. But I really liked GraphQL compared to the API tests that I used to do. And it was because GraphQL is really client and consumer
00:12:32
Speaker
uh oriented so basically uh yeah so you you got the schema is different is whatever you send you got the return for for just what you send um so i thought that was oh my god that is so cool i don't need to you know verify everything and just verify whatever is the return so this was the main difference and
00:12:55
Speaker
And also, you know, HTTP, HTTP, you have, you have to check, you know, both to get all these kind of different protocols, protocols, sorry, you know, you need to check all these things. And with GraphQL, we just post and you don't need to check all these differences as well.
00:13:16
Speaker
But the main thing was definitely the response because it's just client oriented, more client oriented. So yeah, I would prefer actually. Yeah,

Functional Testing in Web3

00:13:31
Speaker
that's really interesting because again, there's like the reason why contract testing exists, right? Is because it was trying to make APIs more consumer led.
00:13:44
Speaker
So yeah, it's interesting you made the comparison again around GraphQL being more client consumer led. So it seems like the tool was married up quite nicely in that respect. Yeah, yeah, no, definitely. And also, I remember that, you know, contract tasks, they do just a part of the tasks. And even if it is because some people, they think, oh, okay, I have contract tasks set up and they don't need to worry about anything anymore.
00:14:11
Speaker
in this layer, but then I remember we had to think about performance tests and all these other things that usually we don't worry too much when we are doing API tests because it's together, but then I remember we had to really think about that. This is not something that most of the projects that I have
00:14:39
Speaker
I've worked before, they were worried as well, you know, performance tests and less, depending on the size of the company, to be honest, if the company is big like HMRC, now they are really focused on performance, but when it's a small company, they don't care too much. And then I remember we did just API tests and we did like performance kind of together, which is no idea, of course. Yeah.
00:15:08
Speaker
As you say, when you're working on a small scale, it makes sense. And now you've got auto scaling and things like that. You don't have to worry too much. It is often the case of, yeah, you've not thought about a scenario. And I can imagine that happens in GraphQL as well as like, because obviously you're searching all of the data. So you have to take those things into consideration.
00:15:33
Speaker
Yeah, no, definitely. I'm trying to remember all the details, but I remember, yeah, mainly the, yeah, this consumer driven was mind blowing for me. Definitely. And, and the problem that had with the retrieving the data from the body, kind of, yeah, something like that.
00:15:57
Speaker
But I think these are the main points when I was doing GraphQL and using Python for the contract sizes. And then I remember we, because the project didn't last long, unfortunately, which was a shame for everybody, but I remember that we even
00:16:19
Speaker
We were even able to add the proxy broker and everything in the pipeline. So it was really nice to see things breaking. That's cool. I really appreciate you taking your mind back to that because I don't have that experience. It's great to get people on who have a variety of experience. So that's really helpful.
00:16:49
Speaker
No. And so, yeah, let's kind of touch briefly before we wrap up around kind of the Web3 kind of testing base. So you mentioned before about the kind of smart contracts and stuff. So, yeah, if anyone's interested in that, how would you explain to them what kind of testing you'd be doing around that?
00:17:13
Speaker
Oh, okay. So on that space, to be honest, the functional tests, they are quite similar because you still need to test things, for example, you know, the transaction, which
00:17:28
Speaker
I'm trying to see if there is too much difference between web treatises and any other test that you would do for, for example, a financial company. Because basically, you need two tasks, transaction, if the transaction was done and if the transaction is in the blockchain, the block was added.
00:17:51
Speaker
And then basically is like testing database. I think I can compare to that if I'm not wrong. But yeah, I think you can compare to kind of testing like a transaction between a database.
00:18:09
Speaker
And yeah, you have this proof of work that it is the part where you make sure that whatever was agreed about generating your algorithm. And I don't want to be really technical because if I go too much, maybe it's too complex. But basically, just for people that are interested and it's just the beginning,
00:18:37
Speaker
Yeah, you can compare about testing the transactions between the database and a client, a consumer. Yeah. This is the problem. When I start to learn about blockchain, I thought, oh my God, this is so complex. And then you need to think about how to explain these in really simple way and not scare people.
00:19:07
Speaker
Yeah, I think that's a really useful, something that everyone can relate to, hopefully that listens to the podcast. And yeah, I think it's similar when you're trying to explain to people about contract testing is you're like, okay, there's a broker and there's a consumer and a provider. And then you're like, wait a minute, I've got to explain all those three things before you even get to explain what it is. So it's like, yeah, I can see the terminology and things I get to
00:19:35
Speaker
Very quickly. Yeah. And you know, because blockchain, because Webitree is, it is like an umbrella of things. So you can consider like metaverse, blockchain, everything is inside. But basically, you need to know blockchain, what is the technology, what does, and then you can understand everything on top, because everything is built on top of blockchain technology, kind of.
00:20:02
Speaker
Yeah. And I think I'm really, yeah, I advocate a lot about web tree and blockchain because on C, you know what it is. You kind of get addicted because you think, oh my God, this is the future. Yeah, definitely. Especially

Impact of AI on QA Industry

00:20:18
Speaker
when you see all the things that are happening now.
00:20:21
Speaker
No, I definitely think there's lots of use cases out there that aren't utilizing it, that could be utilizing it. So yeah, 100%. I think there's lots of opportunity in that space. Yeah. Well, let's see because AI now is taking this post line.
00:20:44
Speaker
Yeah, AI definitely will help us do our jobs and will create new jobs. Oh my god, I'm so glad you agree with me because I had this talk before
00:20:59
Speaker
And we were talking about what was going to be the future of AI. And somebody said, QA and developers, they are going to be ending. It's going to be the end of our jobs. And yeah, exactly. I don't think it is that, because this is like super extreme, isn't it? But then, yeah, I thought, oh my god, we just need to adapt as we have done
00:21:28
Speaker
since the beginning of the times I guess yeah exactly yeah and yeah I think in your job kind of moving around technologies and things you'll be pretty safe of a simple computer algorithm yeah no definitely cool cool so I think we'll wrap up the the episode but yeah I just wanted to say thank you again and great to chat with you finally