PromptPex: Automatic Test Generation for Language Model Prompts
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) are being used in many applications and prompts for these models are integrated into software applications as code-like artifacts. These prompts behave much like traditional software in that they take inputs, generate outputs, and perform some specific function. However, prompts differ from traditional code in many ways and require new approaches to ensure that they are robust. For example, unlike traditional software the output of a prompt depends on the AI model that interprets it. Also, while natural language prompts are easy to modify, the impact of updates is harder to predict. New approaches to testing, debugging, and modifying prompts with respect to the model running them are required. To address some of these issues, we developed PromptPex, an LLM-based tool to automatically generate and evaluate unit tests for a given prompt. PromptPex extracts input and output specifications from a prompt and uses them to generate diverse, targeted, and valid unit tests. These tests are instrumental in identifying regressions when a prompt is changed and also serve as a tool to understand how prompts are interpreted by different models. We use PromptPex to generate tests for eight benchmark prompts and evaluate the quality of the generated tests by seeing if they can cause each of four diverse models to produce invalid output. PromptPex consistently creates tests that result in more invalid model outputs than a carefully constructed baseline LLM-based test generator. Furthermore, by extracting concrete specifications from the input prompt, PromptPex allows prompt writers to clearly understand and test specific aspects of their prompts. The source code of PromptPex is available at https://github.com/microsoft/promptpex.
Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Builds on 26 of its 95 references that are in the map. First posted on arXiv 7 Mar 2025.
Builds on
26 of 95 references.
References · 26
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,998
- 2023Large Language Models are not Fair Evaluatorscited by 1,085
- 2023DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelinescited by 832
- 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 653
- 2023GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Promptscited by 560
- 2024Large Language Models for Data Annotation and Synthesis: A Surveycited by 205
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 194
- 2024Pride and Prejudice: LLM Amplifies Self-Bias in Self-Refinementcited by 114
- 2023No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generationcited by 82
- 2023Using Large Language Models to Generate JUnit Tests: An Empirical Studycited by 53
- 2023FuzzLLM: A Novel and Universal Fuzzing Framework for Proactively Discovering Jailbreak Vulnerabilities in Large Language Modelscited by 51
14 more
- 2024SPML: A DSL for Defending Language Models Against Prompt Attackscited by 34
- 2024On the Evaluation of Large Language Models in Unit Test Generationcited by 34
- 2023ChatGPT vs SBST: A Comparative Assessment of Unit Test Suite Generationcited by 32
- 2024Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimizationcited by 30
- 2023(Why) Is My Prompt Getting Worse? Rethinking Regression Testing for Evolving LLM APIscited by 23
- 2024MAPO: Boosting Large Language Model Performance with Model-Adaptive Prompt Optimizationcited by 21
- 2023ParaFuzz: An Interpretability-Driven Technique for Detecting Poisoned Samples in NLPcited by 19
- 2024SPADE: Synthesizing Data Quality Assertions for Large Language Model Pipelinescited by 19
- 2024GhostWriter: Augmenting Collaborative Human-AI Writing Experiences Through Personalization and Agencycited by 18
- 2024PROMPTFUZZ: Harnessing Fuzzing Techniques for Robust Testing of Prompt Injection in LLMscited by 17
- 2024Specifications: The missing link to making the development of LLM systems an engineering disciplinecited by 17
- 2023Unit Test Generation using Generative AI : A Comparative Performance Analysis of Autogeneration Toolscited by 13
- 2024Test Oracle Automation in the era of LLMscited by 11
- 2024RETAIN: Interactive Tool for Regression Testing Guided LLM Migrationcited by 3
Built on by
Citing papers per year: 2025: 5; 2026: 4.
9 papers.
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 15
- 2026Willful Disobedience: Automatically Detecting Failures in Agentic Tracescited by 6
- 2025Sharing State Between Prompts and Programscited by 2
- 2025Clotho: Measuring Task-Specific Pre-Generation Test Adequacy for LLM Inputscited by 1
- 2025From Benchmark Data To Applicable Program Repair: An Experience Reportcited by 0
- 2025Prompt Less, Smile More: MTP with Semantic Engineering in Lieu of Prompt Engineeringcited by 0
- 2026Imprompt: A Language Framework for Prompt Programmingcited by 0
- 2026Agents as Software: A Programming Languages Agenda for Agent Reliabilitycited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoningcited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoning1 Oct 2026
- 2026Agents as Software: A Programming Languages Agenda for Agent Reliability26 Sep 2026
- 2026Imprompt: A Language Framework for Prompt Programming13 Jul 2026
- 2026Willful Disobedience: Automatically Detecting Failures in Agentic Traces25 Mar 2026
- 2025Sharing State Between Prompts and Programs16 Dec 2025
- 2025Prompt Less, Smile More: MTP with Semantic Engineering in Lieu of Prompt Engineering24 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Clotho: Measuring Task-Specific Pre-Generation Test Adequacy for LLM Inputs22 Sep 2025
- 2025From Benchmark Data To Applicable Program Repair: An Experience Report22 Aug 2025