diff --git a/courseProjectCode/Metrics/Readme.md b/courseProjectCode/Metrics/Readme.md new file mode 100644 index 0000000000..0819f0e1ae --- /dev/null +++ b/courseProjectCode/Metrics/Readme.md @@ -0,0 +1,36 @@ +# Setup and Running Testability Metrics + +## Setup Instructions + +1. Clone the repository + + - git clone your-repo-url + - cd cli-swen777 + +2. Install dependencies and setup environment + + - make + + The above command will: + - Create a virtual environment inside ./venv + - Install all dependencies + - Install HTTPie in editable mode + - Run the test suite once + +3. Activate the virtual environment + + - source venv/bin/activate + +4. Run the testability metrics script + + - python3 courseProjectCode/Metrics/Testability.py + + The above command will: + + - Run all tests with coverage enabled + - Generate a coverage report + - Output the total number of test cases and test suites + +![](report.png) + + diff --git a/courseProjectCode/Metrics/Testability.py b/courseProjectCode/Metrics/Testability.py new file mode 100644 index 0000000000..9b8efb70dc --- /dev/null +++ b/courseProjectCode/Metrics/Testability.py @@ -0,0 +1,27 @@ +import subprocess # Import subprocess to run shell commands from Python + +def run_command(command): # function to execute shell command and returns its output as a string + result = subprocess.run(command, shell=True, capture_output=True, text=True) + return result.stdout.strip() + +def count_test_cases(): # Fucntion to count total test cases by collecting pytest functions + output = run_command("pytest --collect-only | grep '