www.cusc.vn Niềm tin - Đam mê - Trách nhiệm Manual Software Testing and AI-Supported Test Case Design Smart Testing with AI in the CI/CD Pineline
Session 2.2: Using AI to Generate Test Cases from Requirements 2 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Definition Artificial Intelligence (AI) is a branch of computer science focused on developing computer systems capable of simulating human cognitive functions such as learning, reasoning, problem-solving, pattern recognition, natural language understanding, and decision-making. Example Virtual assistants like Siri, Alexa. Facial recognition on smartphones. Content recommendation systems on social media. www.cusc.vn 3 What is AI? - Basic Definition Niềm tin - Đam mê - Trách nhiệm
www.cusc.vn 4 What is AI? - Basic Definition Niềm tin - Đam mê - Trách nhiệm Artificial Intelligence (AI) is the ability of machines (computers, phones, robots, etc.) to mimic human thinking, learning, and problem-solving. 🔍 Example : Human : Sees a cat and immediately recognizes it as a cat, even if never seen before. AI : Trained with thousands of cat images to recognize a cat, even a new one
www.cusc.vn 5 What Can AI Do? Niềm tin - Đam mê - Trách nhiệm Field Application 📱 Smartphone Facial unlock, word suggestions while typing 🛍️ Online Shopping Product recommendations based on browsing history 🎵 Music Listening Spotify/YouTube Music suggests mood-based playlists 🧠 Education ChatGPT explains lessons, Duolingo for language practice 📷 Social Media TikTok/Instagram understands user preference 🚗 Transportation Autonomous vehicles , Google Maps smart routing AI applications are ubiquitous .
The Evolution of AI 1 1950s Initial AI research with early computers Development Phase Machine learning algorithms and modern AI technique Current Boom Driven by Big Data and superior computational power 3 2 www.cusc.vn 6 Niềm tin - Đam mê - Trách nhiệm
www.cusc.vn 7 Niềm tin - Đam mê - Trách nhiệm Basic AI Classification Narrow AI (ANI) Specialized in specific tasks, e.g., playing chess, language translation, solving logical problems. General AI (AGI ) Intelligence comparable to humans, capable of learning and reasoning across multiple domains.
www.cusc.vn 8 Niềm tin - Đam mê - Trách nhiệm www.cusc.vn 8 ML – Machine Learning Data Input Big data collection and analysis machine. Searching for Patterns Enhance your skills using AI in your daily work. Learn and predict Automatically improve results over time. Branches of AI AI is like "mathematics," with many important sub-disciplines: Machines learn from data. Just like you learn how to do math after seeing many sample problems. For example, ML learns to distinguish spam by looking at thousands of "spam" and "not spam" emails.
www.cusc.vn 9 Niềm tin - Đam mê - Trách nhiệm DL – Deep Learning Multi-layered neural networks Process complex data like images, text. Applications Speech recognition, language translation, automation. Uses artificial neural networks to mimic human brain functions
www.cusc.vn 10 Niềm tin - Đam mê - Trách nhiệm Natural Language Processing (NLP) Enables machines to understand and process natural language. The technology behind ChatGPT, machine translation, chatbots ...
www.cusc.vn 11 Niềm tin - Đam mê - Trách nhiệm What is Generative AI (GenAI) ? Pattern Learning GenAI learns based on large language models (LLMs) Create new content Generate text, images, and audio that match the prompt. Diverse applications From music composition, filmmaking, to design support.
Number of parameters of LLMs
Summary of Concepts
www.cusc.vn 14 Niềm tin - Đam mê - Trách nhiệm Comparison of GenAI vs. Traditional Traditional AI Focuses on analyzing, predicting, and classifying existing data. - Structured data - Used in forecasting and automation Generative AI (GenAI) Focuses on creating new content like text, images. - Creative and flexible output. - Supports multimedia generation.
www.cusc.vn 15 Niềm tin - Đam mê - Trách nhiệm Popular Applications of GenAI Text ChatGPT-OpenAI Gemini-Google Copilot-Microsoft Image/Video Midjourney DALL-E Sora-OpenAI Veo -Google
What is Prompt Engineering? 16 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm Prompt Engineering is the method by which we guide AI to perform tasks through the design and optimization of prompts. It serves as a crucial bridge that helps AI understand and accurately execute human requests, particularly when interacting with large language models (LLMs).
Use AI for Writing Test Cases Why Use AI for Writing Test Cases? Explore the benefits of integrating AI into your testing workflow. Writing Effective Prompts Master the art of crafting precise AI prompts for optimal results. Hands-On Practice Apply your knowledge by generating and refining test cases with AI. 17 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Why Use AI for Writing Test Cases? Integrating Artificial Intelligence (AI) into software testing is not just a trend; it's a strategic move to significantly enhance quality and expedite processes. AI acts as a force multiplier, allowing testers to achieve more with less effort, and focus on higher-value activities. 18 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Benefits of AI in Test Case Generation Increased Speed AI can generate hundreds of test cases in seconds, a task that would take hours manually. You provide requirements, and AI handles the rest. Increased Coverage AI analyses requirements from multiple angles, suggesting scenarios and edge cases human testers might overlook. Time Savings for Complex Tasks Automating repetitive test case writing frees up time for exploratory testing, in-depth requirement analysis, and script automation. 19 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
From Basic to Detailed Prompts Basic Prompt "Write test cases for the login feature on a website." Result: Generic test cases lacking specific details like field names, data, or precise expected results. Requires significant manual refinement. Detailed Prompt "Based on https://www.saucedemo.com/ , write detailed test cases for the login feature. Include valid, invalid, and locked-out account scenarios. Use a table format with Test Case ID, Title, Steps, Expected Result, and Test Data columns." Result: Comprehensive, structured test cases ready for use, minimising manual adjustments. 20 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Effective Prompt Writing Techniques to Maximize the Power of GenAI 1. Clearly Define the Objective of the Prompt Before writing a prompt, determine exactly what task you want the AI to perform Sample Prompt: "Write 5 test cases to verify the login functionality of saucedemo.com, including both valid and invalid scenarios." ChatGPT- Output: 21 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm Here’s a clean, well-structured set of 5 test cases for Saucedemo’s login functionality, covering both valid and invalid scenarios:
22 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm ID Test Case Name Precondition Steps Test Data Expected Result TC_LOGIN_01 Valid Login User is on login page 1. Enter standard_user in Username field2. Enter secret_sauce in Password field3. Click Login Username: standard_userPassword: secret_sauce Navigate to Inventory page with title “Products” TC_LOGIN_02 Invalid Username User is on login page 1. Enter wrong_user in Username field2. Enter secret_sauce in Password field3. Click Login Username: wrong_userPassword: secret_sauce Show error: “Epic sadface: Username and password do not match any user in this service” TC_LOGIN_03 Invalid Password User is on login page 1. Enter standard_user in Username field2. Enter wrong_pass in Password field3. Click Login Username: standard_userPassword: wrong_pass Show error: “Epic sadface: Username and password do not match any user in this service” TC_LOGIN_04 Empty Fields User is on login page 1. Leave Username and Password fields empty2. Click Login (empty) Show error: “Username is required” TC_LOGIN_05 Locked Out User Login User is on login page 1. Enter locked_out_user in Username field2. Enter secret_sauce in Password field3. Click Login Username: locked_out_userPassword : secret_sauce Show error: “Epic sadface : Sorry, this user has been locked out.” Sample Prompt: "Write 5 test cases to verify the login functionality of saucedemo.com, including both valid and invalid scenarios.“ Chat GPT-Output:
Effective Prompt Writing Techniques to Maximize the Power of GenAI 2.Provide Complete and Detailed Information GenAI works best when you include all relevant details: test data, actions, expected results, etc. Sample Prompt: "Create a Selenium WebDriver script in Python to log in to saucedemo.com with the account standard_user / secret_sauce and verify the Inventory page title." ChatGPT- Output: 23 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm Here’s a Selenium WebDriver Python script that logs in to Saucedemo with standard_user / secret_sauce and verifies the Inventory page title. (code python)
Effective Prompt Writing Techniques to Maximize the Power of GenAI 3.Use Context to Clarify the Request Context helps the AI understand the purpose and scope of the task. Sample Prompt : "You are a QA Engineer. Create a checklist to verify the login functionality of saucedemo.com, including: form validation, error messages, password security, and post-login navigation." ChatGPT-Output: 24 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Effective Prompt Writing Techniques to Maximize the Power of GenAI 4.Use Open-Ended Questions and Clear Commands Open-ended questions encourage creative responses; clear commands ensure accuracy. Sample Prompt : "List the boundary test cases for the username and password fields on the saucedemo.com login form." ChatGPT-Output: 25 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Effective Prompt Writing Techniques to Maximize the Power of GenAI 5.Specify Writing Style and Tone Defining style helps AI deliver results that match your needs—for example, technical tone, tables, or checklists. Sample Prompt : "Write a login test case table for saucedemo.com in Markdown format, using a technical tone." ChatGPT-Output: 26 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Anatomy of an Effective Prompt A good prompt is like a detailed job request. You need to provide the AI with enough context and rules to get the most accurate results. Context Specify the system or website, e.g., saucedemo.com . Rules & Data Define valid/invalid accounts, specific scenarios to cover, and test data. Format Request a structured output, such as a table with specific columns. 27 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Practice: Generating Test Cases with ChatGPT User Story "As a user, I want to add products to my cart so I can shop more conveniently." Analysis Actor : Logged-in user Action : Adding product to cart Outcome : Product added, cart quantity updates Scenarios : Single product, multiple, remove, cart interface. 28 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Crafting Your Practice Prompt Let's combine our user story analysis with effective prompt writing techniques. "Based on https://www.saucedemo.com/ (assuming a logged-in user), write detailed test cases for the 'add to cart' functionality. Include scenarios for adding single/multiple products, checking cart count, and removing products. Format as a table with Test Case ID, Title, Steps, Expected Result, and Test Data." Now enter this prompt into ChatGPT and observe the AI-generated results. 29 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Evaluate and Refine AI-Generated Test Cases After the AI generates results, it's crucial to apply your analytical skills to filter and refine them. Check for Accuracy Compare AI output with the actual website interface. Are button names correct? Where is the cart icon located? Identify Missing Cases Note any scenarios the AI missed (e.g., adding then immediately removing). 30 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Evaluate and Refine AI-Generated Test Cases After the AI generates results, it's crucial to apply your analytical skills to filter and refine them. Check for Coverage Review AI-generated scenarios. Did it miss cases like adding an already added product or removing all items? Refine and Complete Modify test cases for accuracy and detail. Add missing columns (e.g., Status) and scenarios. 31 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm
Key Takeaways & Next Steps AI is a Powerful Tool: Use AI to significantly increase the speed and coverage of your test case generation. Prompts Matter: The quality of your AI output directly depends on the detail and clarity of your prompts. Human Oversight is Crucial: Always evaluate and refine AI-generated test cases. Combine AI's efficiency with your critical thinking. Continue practising with different user stories and functionalities to master this skill! 32 www.cusc.vn Niềm tin - Đam mê - Trách nhiệm