Skip to content

Latest commit

 

History

History
99 lines (82 loc) · 3.85 KB

File metadata and controls

99 lines (82 loc) · 3.85 KB

🧪 Lab 30: AI Test Suggestion Pipeline

📝 Lab Summary

This lab focused on using code analysis and AI-assisted reasoning to generate targeted test suggestions. It combined source inspection, suggestion generation, and pipeline validation in a small project environment.

🎯 Objectives

  • Build an AI-powered pipeline to analyze code changes
  • Generate intelligent test suggestions based on code modifications
  • Integrate OpenAI-compatible APIs for test coverage analysis
  • Implement automated test gap detection in a CI/CD workflow

📌 Prerequisites

  • Basic understanding of Python programming
  • Familiarity with Git and version control concepts
  • Basic knowledge of unit testing principles
  • Experience with command-line operations in Linux
  • Understanding of REST APIs and JSON

🖥️ Lab Environment

  • Platform: Ubuntu 24.04 LTS cloud lab environment
  • User: toor
  • Host: ip-172-31-10-252
  • Shell: Bash

🛠️ Task Overview

Task 1: Build Code Change Analyzer

  • Create Project Structure
  • Implement Code Analyzer
  • Create src/code_analyzer.py
  • Create Sample Project for Testing
  • Create sample_project/calculator.py
  • Test Code Analyzer
  • Create tests/test_analyzer.py

Task 2: Implement AI Test Suggester

  • Set Up Local AI Model (Ollama)

Task 3: Implement AI Test Suggester

  • Create Test Suggester Module
  • Create src/test_suggester.py
  • Create Pipeline Orchestrator
  • Create src/pipeline.py
  • Run the Complete Pipeline
  • Create a New Change to Test Pipeline

📁 Repository Structure

lab30-ai-test-suggestion-pipeline/
└── README.md
└── commands.sh
└── interview_qna.md
└── output.txt
└── sample_project/
    └── calculator.py
└── src/
    └── code_analyzer.py
    └── pipeline.py
    └── test_suggester.py
└── tests/
    └── test_analyzer.py
└── troubleshooting.md

✅ Verification & Validation

  • Confirmed the environment and toolchain were installed correctly
  • Validated the core workflow with command execution and captured outputs
  • Preserved scripts, configuration files, and supporting artifacts used during the lab
  • Documented common failure paths and remediation steps in the troubleshooting guide

📚 What I Learned

  • How to inspect code structure to identify missing test coverage ideas
  • How to separate analyzer, suggester, and pipeline responsibilities
  • How to validate AI-assisted testing logic with automated tests
  • How suggestion pipelines can support quality engineering workflows

🌍 Why This Matters

Better test suggestions can improve coverage planning and help teams move faster when analyzing unfamiliar codebases or newly added features.

🚀 Real-World Applications

  • Quality engineering automation
  • Coverage planning
  • Developer assist tooling
  • AI-augmented testing workflows

🔎 Real-World Relevance

The workflow in this lab maps well to practical cloud, DevOps, software assurance, and security operations responsibilities where repeatable procedures and evidence-backed validation matter.

✅ Result

The AI-assisted test suggestion pipeline successfully analyzed code structure and produced targeted testing guidance through a reproducible workflow.

🏁 Conclusion

You’ve successfully built an AI-powered test suggestion pipeline that:

  • analyzes code changes using Git and AST parsing
  • extracts function complexity metrics
  • generates test suggestions using a local-model workflow with fallback support
  • produces actionable JSON and Markdown outputs for improving coverage

This workflow fits the goal of the uploaded lab: use code-diff awareness plus structured function analysis to surface likely missing tests before code is merged or deployed. The local-model path supports privacy-preserving automation, and the fallback path keeps the workflow usable even when model output is slow or malformed.