Chat gpt and testdatacreation

Mar 19, 2024 | by Ralph Van Der Horst

Chat GPT and Testdatacreation

How We Use ChatGPT in Consultancy: A Blog Series Preview

Introduction: In this series, I will walk you through hands-on demonstrations of how we leverage ChatGPT in our daily consultancy activities.

Today’s Experience: Today I was talking to a Tosca expert(very hard working guy though) and we were talking about how long it would take to parse a xml data set to generate a bsn structure for a certain activity for one projects. I gave him the challenge to do it totally different and he choose for python

The Big Question: So the question was: Can ChatGPT help the low code developer/tester help him create a python script by which does not have any former programmer skills? The answer is 😅… yes ;-),but 🚀

Yes, ChatGPT can indeed assist in crafting a Python script even for a tester who lacks programming expertise. 😃 However, there are certain nuances and complexities in scripting that might require a deeper dive or some hands-on practice to fully getting hold on it. But with the right guidance anything is possible!

Step-by-Step Guide:

The first thing I advised him to do is installing faker

Setting Up: Start by installing Faker, a library that can generate mock data in various languages. This will be handy for populating our XML structure.

pip install Faker

Crafting the Script: To structure the XML, use ET.Element:

This can generate mock data for any language which can be used in the xml structure to be created. Second import which ChatGPT gave us and I never heard of (the above one I did) is ET.Element. This actually setups a an elementtree object for xml and you can then enter data based on the tag structure

from faker import Faker
import xml.etree.ElementTree as ET

fake = Faker('nl_NL')  # Dutch locale

def generate_dutch_citizen_data():
    citizen = ET.Element("citizen")

    # First name and last name
    name = ET.SubElement(citizen, "name")
    name.text = fake.name()

    # BSN
    bsn = ET.SubElement(citizen, "bsn")
    bsn.text = fake.ssn()  # In the Dutch locale, ssn() generates a BSN.

    return citizen

def main():
    root = ET.Element("citizens")

    # Generate data for 10 citizens
    for _ in range(10):
        citizen = generate_dutch_citizen_data()
        root.append(citizen)

    # Convert the XML data to a string and save
    tree = ET.ElementTree(root)
    tree.write("dutch_citizens_data.xml")

if __name__ == "__main__":
    main()

When the script has be made it is possible to run this script with python scriptname.py

The output is like this.

<citizens>
    <citizen>
        <name>Full Name of Citizen 1</name>
        <bsn>BSN of Citizen 1</bsn>
    </citizen>
    <citizen>
        <name>Full Name of Citizen 2</name>
        <bsn>BSN of Citizen 2</bsn>
    </citizen>
    ...
    <citizen>
        <name>Full Name of Citizen 10</name>
        <bsn>BSN of Citizen 10</bsn>
    </citizen>
</citizens>

s

Conclusion

It’s incredibly speedy, and both Python and JavaScript excel at generating this data. By integrating it with tools like Tosca and Katalon, or open-source options like Robot Framework, WDIO, and Cypress, you can significantly enhance your test data management and test automation success." Caviats are: you still need to have some programming skills. It is nice that Chatgpt generates code and does suggestions but still you have to interpret if the code is efficient and working. So for a nontechnical tester. Dive into the studybooks and learn!

More things which can be done with ChatGPT are:

  • Creating Test Cases: ChatGPT can help make test cases for your software. If you tell it what a user does on a website, it can think of different situations to test. Like, what happens if the password is wrong? Or if a user tries to log in too many times?
  • Writing Test Documents: Need to write down how you tested? Or the results? ChatGPT can help you write these documents.
  • Exploring Software: ChatGPT can help testers look around the software to find mistakes by talking to it.
  • Guessing Where Bugs Are: ChatGPT can try to guess where the software might have problems. This helps testers know where to look first.
  • Helping Teams Talk: Sometimes it’s hard for people who know a lot about technology to talk to people who don’t. ChatGPT can help them understand each other by turning what they say into test steps.

This is just the start. There’s a lot more we can do with AI in testing and I believe it has a lot of potential

More information on how to create this example Python File can be found in my example repo

https://gitlab.com/learnautomatedtesting/createtestdatapythonbsn

Follow me on LinkedIn: www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=ralphvanderhorst if you have any questions

by Ralph Van Der Horst

arrow right
back to blog

share this article

Relevant articles

AI Generated course leveraging on Chat gpt

AI Generated course leveraging on Chat gpt

How to Create a Great API A Guide for functional performance security

Mar 7, 2024

How to Create a Great API A Guide for functional performance security

The Purpose of E2E Testing in DevOps

Feb 25, 2024

The Purpose of E2E Testing in DevOps