logo
Menu
Using Amazon Q Developer to help test my application

Using Amazon Q Developer to help test my application

How using Amazon Q Developer can help developers with different tasks you need to test your code and application

Ricardo Sueiras
Amazon Employee
Published Apr 30, 2024
In a previous post I shared how I am using Amazon Q Developer to help me work with my stakeholders, ask better questions, and develop my application. In this post, I explore how I am using Amazon Q Developer to help me test the code and the application.
I have had a long time interest in testing software, and more broadly the infrastructure we deploy our software into. In fact, my first ever publicly published article over 20 years ago, was a feature on my approach to testing applications at scale. There are many kinds of testing, but I only want to cover a subset of those in this post (if folk are interested, I will revisit the others in a future post, so leave a comment), specifically those that we as software developers can use to help us build better software.
Specifically I want to look at three areas that I have been experimenting with. The first is around how I can use next generation developer tools like Amazon Q Developer to help me craft unit tests for my code. Following that, I will explore how we can use Amazon Q Developer to help us create synthetic data. Finally, I will take a look at security testing, both how Amazon Q Developer can help you discover and the suggest fixes.
Writing unit tests
In the first video, working with the code that I have built up in the previous posts (which you can grab for yourself here if you want to try this for yourself), I use Amazon Q Developer Agent for software development to "Create unit tests for this project". You will see in the video how we can look at the output from Amazon Q Developer, and then suggest changes we want to make - we do not have to settle for the first thing it suggests, and this is an important thing when working with tools like Amazon Q Developer. They provide a great starting point, but you can interact with it via the chat, to change and improve your outcome.
Creating Synthetic data
In these next two videos, I look at another useful way that I am using these next generation developer tools like Amazon Q Developer, to help me generate synthetic data that will help me test my application, perhaps allowing me to show how these might look in the real world. This is something you might need to do when you are prototyping your application, or creating simple proof of concepts.
In the first video, I take the existing application I have been working on, and get Amazon Q Developer Agent for software development to generate code that will create sample data which I can then test within the application.
More recently, I used Amazon Q Developer Agent for software development to help me generate synthetic data in SQL. I have spent that last few weeks doing demos and talks on a number of open source topics. As I was preparing the talk and code for one meet-up, the other speaker was going to base their demo around an event driven pizza delivery system. I thought I would change my demo and piggy back off the same theme. I just needed some demo data for my database. As it happens, I was able to use Amazon Q Developer Agent for software development to provide this very quickly indeed.
Security Testing and Fixing
Security is your most important priority, and so finding out whether tools like Amazon Q Developer can help us here is going to be a big win for us. I mean, sometimes we ship code with bugs that are not caught till later on, so being able to find them and then fix them at this stage will save a lot of effort and provide more confidence to other stakeholders.
Sticking with my sample application, once I had a working application I kicked off a Security Scan from the Amazon Q plugin in my IDE. The scan detected a potentially worrying bug, CWE-352 Cross-site request forgery.
Running a security scan from Amazon Q Developer
I was able to use the hot link from the report to go straight to the code in question.
Reviewing the affected code for CWE-352
And in this case, Amazon Q Developer was able to suggest a fix.
Amazon Q Developer is able to suggest a fix for this issue
I clicked on this link, Amazon Q Developer update my code, and then when I re-ran the scan, I was now completely clear.
Try Amazon Q Developer and see how it can help you with your application testing needs
In this short post, I wanted to quickly share how Amazon Q Developer Agent for software development can help developers with the different types of testing that we need to do, to ensure we ship working software. Whether this is creating unit tests, creating synthetic data to validate and test our applications, or how we can use security testing together with Amazon Q Developer to help fix anything that comes up, next generation developer tools like Amazon Q Developer can help you with all your testing tasks.
Stay tuned for more adventures in Amazon Q Developer, and as always, I would love to hear your stories and what you are doing with Amazon Q Developer. Find more ways that Amazon Q Developer can help you by checking out the Developer Centre resources.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments