Skip to content

A simple python project to show how automated software testing framework works with examples using Python, HTML reports, and shell scripts.

Notifications You must be signed in to change notification settings

snowholt/softwareTesting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Personal Finance Calculator - Software Testing Project

A simple Python project demonstrating Unit Testing, Integration Testing, and System Testing methodologies.

πŸ“‹ Project Overview

This project implements a basic Personal Finance Calculator with comprehensive testing to demonstrate different levels of software testing. The calculator performs common financial calculations such as loan payments, compound interest, and savings goals.

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ finance_calculator/
β”‚   β”œβ”€β”€ __init__.py          # Package initialization
β”‚   β”œβ”€β”€ calculator.py        # Core calculation functions
β”‚   β”œβ”€β”€ validator.py         # Input validation logic
β”‚   └── main.py             # Main application interface
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py         # Test package initialization
β”‚   β”œβ”€β”€ test_unit.py        # Unit tests
β”‚   β”œβ”€β”€ test_integration.py # Integration tests
β”‚   └── test_system.py      # System tests
β”œβ”€β”€ requirements.txt        # Project dependencies
└── README.md              # This file

πŸ”§ Features

Core Functionality

  • Simple Interest Calculation: Calculate simple interest on investments
  • Compound Interest Calculation: Calculate compound interest with different frequencies
  • Loan Payment Calculator: Calculate monthly payments for loans
  • Savings Goal Calculator: Determine time needed to reach savings targets
  • Input Validation: Comprehensive validation of user inputs

πŸ§ͺ Testing Methodology

1. Unit Testing (test_unit.py)

Purpose: Test individual functions and methods in isolation.

Tests Include:

  • βœ… Individual calculation functions (simple interest, compound interest, loan payments)
  • βœ… Input validation methods
  • βœ… Edge cases and boundary conditions
  • βœ… Error handling for invalid inputs
  • βœ… Mathematical accuracy verification

Example:

def test_simple_interest_calculation(self):
    result = self.calculator.calculate_simple_interest(1000, 5, 2)
    self.assertEqual(result, 100.0)  # (1000 * 5 * 2) / 100 = 100

2. Integration Testing (test_integration.py)

Purpose: Test how different components work together.

Tests Include:

  • βœ… Calculator + Validator integration
  • βœ… Main App coordination of components
  • βœ… Data flow between modules
  • βœ… Component interaction workflows
  • βœ… End-to-end calculation processes

Example:

def test_loan_payment_integration(self):
    # Tests validator β†’ calculator β†’ result formatting workflow
    result = self.app.calculate_loan_payment("15000", "4.5", "4")
    self.assertTrue(result['success'])
    self.assertIn('monthly_payment', result)

3. System Testing (test_system.py)

Purpose: Test the complete application from end-user perspective.

Tests Include:

  • βœ… Complete user workflows
  • βœ… System behavior under various conditions
  • βœ… Error handling and recovery
  • βœ… Performance characteristics
  • βœ… Data integrity across operations
  • βœ… User experience consistency

Example:

def test_complete_financial_planning_workflow(self):
    # Tests realistic user scenario combining multiple features
    savings_result = self.app.calculate_savings_time("50000", "800", "2.5")
    loan_result = self.app.calculate_loan_payment("200000", "4.5", "30")
    # Verify realistic financial planning results

πŸš€ Getting Started

Prerequisites

  • Python 3.7 or higher
  • pip (Python package installer)

Installation

  1. Clone or download the project

  2. Navigate to the project directory:

    cd saba_softwareTesting/src
  3. Install dependencies (optional, for enhanced testing):

    pip install -r requirements.txt

Running the Application

Method 1: Using the runner script (Recommended)

# Simple runner script that handles paths automatically
python run_app.py

Method 2: Direct execution with PYTHONPATH

# Set Python path and run directly
PYTHONPATH=. python finance_calculator/main.py

Method 3: Using module execution

# Run as module (may require package installation)
python -m finance_calculator.main

Expected Output:

=== Personal Finance Calculator ===
Simple demonstration of financial calculations

1. Loan Payment Calculation:
Monthly Payment: $306.66
Total Interest: $1,039.76

2. Savings Goal Calculation:
Time to reach goal: 2.1 years
Total contributions: $5,040.00

3. Interest Calculation:
Final amount: $1,083.14
Interest earned: $83.14

πŸ§ͺ Running Tests

Run All Tests

Method 1: Using the test runner script (Recommended)

# Simple test runner that handles paths automatically
python run_tests.py

Method 2: Using unittest with PYTHONPATH

# Set Python path and run with unittest
PYTHONPATH=. python -m unittest discover tests -v

Method 3: Using pytest (if installed)

# Using pytest with proper path
PYTHONPATH=. pytest tests/ -v

Run Specific Test Types

Using the test runner:

python run_tests.py unit         # Unit tests only
python run_tests.py integration  # Integration tests only
python run_tests.py system       # System tests only

Using unittest directly:

Using unittest directly:

PYTHONPATH=. python -m unittest tests.test_unit -v
PYTHONPATH=. python -m unittest tests.test_integration -v
PYTHONPATH=. python -m unittest tests.test_system -v

Test Coverage Analysis

# Generate coverage report (if coverage package is installed)
coverage run -m pytest tests/
coverage report
coverage html  # Generates HTML report

πŸ“Š Test Results Summary

Expected Test Counts:

  • Unit Tests: ~20 test methods
  • Integration Tests: ~8 test methods
  • System Tests: ~8 test methods
  • Total Tests: ~36 test methods

Test Coverage Areas:

  • βœ… Mathematical calculations
  • βœ… Input validation
  • βœ… Error handling
  • βœ… Component integration
  • βœ… User workflows
  • βœ… Edge cases and boundaries
  • βœ… Performance characteristics

πŸ“ˆ Sample Test Output

test_calculate_compound_interest (test_unit.TestFinanceCalculator) ... ok
test_calculate_monthly_payment (test_unit.TestFinanceCalculator) ... ok
test_loan_payment_integration (test_integration.TestFinanceAppIntegration) ... ok
test_complete_loan_analysis_workflow (test_system.TestFinanceAppSystem) ... ok

----------------------------------------------------------------------
Ran 36 tests in 0.123s

OK

🎯 Learning Objectives Demonstrated

  1. Unit Testing: Testing individual components in isolation
  2. Integration Testing: Testing component interactions and data flow
  3. System Testing: Testing complete user scenarios and system behavior
  4. Test Organization: Proper test structure and documentation
  5. Error Handling: Comprehensive validation and error management
  6. Code Coverage: Ensuring adequate test coverage across the codebase

πŸ“ Key Testing Concepts Illustrated

Test Isolation

  • Each test is independent and can run in any order
  • Test fixtures (setUp()) ensure consistent test environment

Test Categories

  • Positive Testing: Testing with valid inputs
  • Negative Testing: Testing with invalid inputs
  • Boundary Testing: Testing edge cases and limits
  • Performance Testing: Basic performance characteristics

Assertion Types

  • Equality: assertEqual(), assertAlmostEqual()
  • Boolean: assertTrue(), assertFalse()
  • Exceptions: assertRaises()
  • Comparisons: assertGreater(), assertLess()

πŸ” Code Quality Features

  • Type Hints: Clear function signatures (could be added for enhancement)
  • Documentation: Comprehensive docstrings and comments
  • Error Handling: Proper exception handling with meaningful messages
  • Validation: Input validation before processing
  • Separation of Concerns: Clear separation between calculation, validation, and interface

πŸ“š Further Enhancements

This basic project can be extended with:

  • Mock Testing: Using unittest.mock for external dependencies
  • Parameterized Tests: Testing multiple inputs with single test methods
  • Test Data Management: External test data files
  • Continuous Integration: Automated testing on code changes
  • Performance Benchmarking: Detailed performance testing
  • GUI Testing: If a graphical interface is added

πŸ‘¨β€πŸŽ“ Assignment Completion

This project demonstrates:

  • βœ… Simple Python Project (achievable in 1 hour)
  • βœ… Unit Testing implementation and examples
  • βœ… Integration Testing implementation and examples
  • βœ… System Testing implementation and examples
  • βœ… Documentation with clear explanations
  • βœ… Structured Code with proper organization
  • βœ… Real-world Application (financial calculations)

Perfect for demonstrating software testing concepts in an academic setting!


Author: Ω”Nariman.J
Course: Software Testing
Date: June 2025

About

A simple python project to show how automated software testing framework works with examples using Python, HTML reports, and shell scripts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published