Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 2.67 KB

File metadata and controls

73 lines (54 loc) · 2.67 KB

Test Smell Detector

📌 Overview

The Test Smell Detector is a Python-based tool designed to analyze a given project directory and detect "test smells." Test smells are patterns in test code that may lead to maintainability issues, reduce test effectiveness, or introduce hidden bugs. This tool helps developers improve the quality of their test suites by providing insights into potential problem areas.

🎯 Purpose

Many software projects suffer from poor test quality due to test smells such as:

  • Lack of proper structure
  • Inefficient test cases
  • Redundant or poorly maintained test methods

This tool systematically scans a given Python project directory and evaluates test-related files across three levels:

  1. Project Level: Checks the entire project structure for test-related issues.
  2. Test Case Level: Analyzes individual test case classes.
  3. Test Method Level: Examines the methods inside test cases.

The detected issues are then compiled into an easy-to-read report.

🛠 How It Works

  1. The tool identifies all Python files within the specified directory (including subdirectories).
  2. It processes the files through three rule-checking stages:
    • Project Level: Evaluates the overall test organization.
    • Test Case Level: Analyzes test case structures.
    • Test Method Level: Examines individual test methods.
  3. The results are formatted and saved into output.txt for review.

Important

It reports test smells for tests which enhirit from unittest.TestCase

🚀 Installation & Usage

Prerequisites

  • Python 3.7+ installed on your system

Running the Tool

  1. Clone this repository:
    git clone git@github.com:TestSmells/PythonTestSmellDetector.git
    cd PythonTestSmellDetector
  2. Run the tool with:
    python smell_detector.py /path/to/your/python/project
  3. Check the output.txt file for results.

📂 Output

The results will be saved in output.txt, formatted as a list of detected test smells along with their locations.

🔥 Example Output

('Test Case has redundant setup', 'tests/test_example.py', 'TestExample')
('Test Method lacks assertion', 'tests/test_example.py', 'test_no_assert')

Each entry specifies:

  1. The detected test smell
  2. The file where it was found
  3. (If applicable) The test case or test method where the issue occurs

📌 Why Use This Tool?

✔ Helps improve test quality by identifying bad practices. ✔ Easy-to-use CLI tool requiring minimal setup. ✔ Supports Python projects of any scale. ✔ Provides actionable insights to refactor test code.


Contributions & Feedback: Feel free to submit issues or contribute to improving this tool! 🚀