# ๐Ÿงช Pankaj-TestCaseGeneration-Mistral ## ๐Ÿš€ Model Overview This project uses a fine-tuned version of **[mistralai/Mistral-7B-Instruct-v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3)**, specialized for **automatically generating software test cases** directly from user stories. Given a user story as input, the model generates a comprehensive set of: - โœ… Positive Test Cases - โŒ Negative Test Cases - โš ๏ธ Edge Case Scenarios This helps QA teams **accelerate test case design** by automating repetitive analysis work. --- ## ๐Ÿงช Model Details | Property | Value | |------------------|-----| | **Base Model** | mistralai/Mistral-7B-Instruct-v0.3 | | **Task** | Test Case Generation (QA Automation) | | **Language** | English | | **Input** | User Story (free text) | | **Output** | Structured Test Cases | --- ## ๐Ÿ‘… How to Use You can use this model directly via the Hugging Face Transformers library in Python. ### Example Code ```python from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "Pankaj/TestCaseGeneration-Mistral" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) prompt = """ User Story: As a user, I want to reset my password so that I can regain access to my account if I forget my password. Test Cases: """ inputs = tokenizer(prompt, return_tensors="pt") outputs = model.generate(**inputs, max_new_tokens=500) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` --- ## โš’๏ธ Training Process The model was **fine-tuned on a custom dataset** containing: โœ… Real-world user stories collected from projects โœ… Manually curated test cases written by experienced QA engineers The fine-tuning was performed using **Hugging Face Transformers** in Python. --- ## ๐Ÿ“š Intended Use This model is designed to: โœ… Automate the first draft of test cases for QA teams โœ… Serve as an **assistive tool** for junior QA engineers or developers โœ… Save time when starting test design from scratch --- ## โœ… Sample Input & Output ### Input ```text User Story: As a user, I want to search for products by name so that I can quickly find items I am interested in. Test Cases: ``` ### Output ```text 1. [Positive] Search for existing product Pre-condition: Product exists in catalog Steps: 1. Navigate to the search page 2. Enter product name in search bar 3. Click "Search" Expected Result: Product is shown in search results 2. [Negative] Search with invalid characters Pre-condition: None Steps: 1. Enter "@@@@" in search bar 2. Click "Search" Expected Result: "No results found" message is shown 3. [Edge] Case-insensitive search Pre-condition: Product exists with lowercase name Steps: 1. Enter product name in uppercase 2. Click "Search" Expected Result: Product still appears in search results ``` --- ## โš ๏ธ Limitations - Output quality may degrade with **very complex or ambiguous user stories**. - Domain-specific terminology (finance, healthcare, etc.) may require **further fine-tuning**. --- ## ๐Ÿ” Handling API Keys Safely To run this project locally, you need a Hugging Face API token. **Recommended Approach:** 1. Create a `.env` file and add: ``` HF_TOKEN=your_hugging_face_token_here ``` 2. Add `.env` to `.gitignore` to avoid accidental exposure. 3. Use this code to read the token: ```python from dotenv import load_dotenv import os load_dotenv() hf_token = os.getenv("HF_TOKEN") ``` --- ## ๐Ÿ’ฌ Feedback and Contributions Contributions are welcome โ€” whether it's improving prompts, enhancing the fine-tuning dataset, or adding new features like **Jira integration** for fetching user stories automatically. Feel free to raise issues, create pull requests, or simply share feedback. Let's make test automation smarter together! โœจ --- ### ๐ŸŽ‰ Happy Testing!