PadhaikoAll subjects

Implementation and Testing

Minor Project (ENCT 354)

Open in the Padhaiko app

4.1 Implementation and deployment of the project

Definition

Implementation and Deployment

Implementation is the phase where system designs, algorithms, database schemas, and circuit schematics are turned into working, integrated code and hardware. Deployment packages and runs that finished system in its target environment—a local server, cloud host, mobile device, or physical embedded enclosure—so real users and examiners can operate it reliably outside the developer's editor.

4.1.1 Turning design into integrated working modules

  1. Follow a strict integration rhythm: Merge feature branches into main at least once a week instead of combining four separate branches two days before submission.
  2. Externalise configuration: Keep port numbers, database file paths, API keys, and Wi-Fi SSIDs in a .env or configuration file (with a .env.example template committed to Git) so no secret is leaked and settings can be changed without editing code.
  3. Seed realistic sample data: An empty dashboard looks broken during a demonstration. Prepare a reproducible seed script that populates sample records, user accounts, and test cases in seconds.
  4. Handle failure gracefully: Add clear error messages, network timeouts, and safe defaults (for instance, showing cached readings or a clear sensor-offline warning instead of crashing with an unhandled exception).

4.1.2 Deployment options for a minor project

Common Deployment Targets for Minor Projects
Project TypePractical Deployment TargetKey Setup StepsDemo-Day Watch-Out
Web ApplicationLocalhost / LAN server, Docker Compose, or free PaaS (Render, Railway, Vercel)Pin dependencies, run DB migrations, set environment variables, serve static assetsCampus Wi-Fi may block ports or sleep free-tier apps; keep a local run command ready
Mobile AppSigned debug/release APK installed on physical Android phonePoint API base URL to reachable LAN IP or hosted URL, test offline statesEmulators lag on presentation laptops; demo directly on a phone or screen-mirror
AI / ML SystemWrapped inside a FastAPI/Flask service or Streamlit/Gradio demo appSave trained model weights (pt/onnx/pkl), match preprocessing pipeline exactlyNever retrain live during defence; load saved weights and test on unseen sample inputs
Hardware / IoTFlashed microcontroller in a neat enclosure + powered sensor/relay boardSolder or secure jumper pins, label terminals, add fuse/flyback protection, bind auto-reconnectLoose breadboard wires break in transit; bring a spare USB cable, power bank, and recorded video

4.1.3 Preparing deployment for final report and defence

Examiners judge both the live system and your engineering discipline during presentation and defence:

Example 4.1

Building a deployment and demo-day readiness checklist

A 4-member group has built a web-based hostel mess-billing and food-feedback portal using React, Python FastAPI, and SQLite, hosted on a free cloud tier. Two days remain before their final minor project defence. Prepare a practical deployment and demo-day readiness plan.

Verify a clean, reproducible deployment: Test cloning the repository into a fresh folder on a second teammate's laptop, installing from requirements.txt and package.json, running the SQLite seed script, and starting both backend and frontend with documented commands.

Guard against network and cloud-tier failures:

Keep both the deployed cloud URL and a verified localhost instance (with seeded sample hostel bills and feedback entries) ready on the presentation laptop, plus a 2-minute fallback video clip.

Prepare defence roles and slide flow: Freeze the main branch, assign each member a clear section of the live demo and slides matching the modules they built, and prepare short answers on database schema choices, test results, and system limitations.

Answer:

The team verifies a clean install on a second machine, prepares a local seeded instance alongside the cloud URL as an offline backup, freezes the main branch, and rehearses a coordinated demo where each member presents their implemented module.

4.2 Testing and validation of the developed system (Unit testing, integration testing, and user testing)

Definition

Verification, Validation, and System Testing

Verification checks whether each module is built correctly according to its technical specification ("Are we building the system right?"). Validation checks whether the complete working system actually solves the user's real problem ("Are we building the right system?"). In a minor project, systematic testing progresses through three levels: unit testing, integration testing, and user testing.

4.2.1 Three levels of testing

  1. Unit testing: Tests the smallest independent units—individual functions, class methods, input validators, SQL helper queries, or sensor-parsing routines—in isolation using mock inputs. It checks normal cases, boundary values (zero, empty string, maximum limit), and error cases (negative quantities, malformed JSON). Common tools include pytest or unittest (Python), Jest (JavaScript), and JUnit (Java).
  2. Integration testing: Tests how two or more modules work together across interfaces—for example, API endpoint + SQLite transaction, microcontroller HTTP POST -> backend parser -> database insert, or image upload -> ML model -> JSON response. Integration tests catch mismatched field names, wrong HTTP status codes, encoding bugs, and timing issues.
  3. User testing (User Acceptance Testing / UAT): Puts the deployed prototype in front of 5 to 15 real target users (or classmates/teachers acting as end users) and asks them to complete realistic tasks without developer hints. Observe where users hesitate, record task completion success and errors, and gather usability feedback to validate the system against the original objectives.
Comparing Unit, Integration, and User Testing
Test LevelScope Under TestWho Runs ItTypical Defect CaughtConcrete Minor-Project Example
Unit TestingSingle function, class, or hardware driverDeveloper (pytest, Jest, serial test script)Off-by-one error, division by zero, wrong validation regexcalculate_fine(days_late=0) returns 0, and days_late=-2 raises ValueError
Integration TestingCombined modules (UI -> API -> DB, MCU -> Server)Developers (Postman, pytest test client, hardware-in-loop)Mismatched JSON keys, DB foreign-key errors, serial baud mismatchPOST /api/return updates Loan.returned_at and sets Book.status = "available" atomically
User Testing (UAT)Complete deployed system in realistic scenariosRepresentative end users (5-15 participants)Confusing button labels, slow workflow, missing error guidance, unreadable mobile layout10 students test book checkout; 9 complete in under 25 s, 1 misses the "Confirm" button leading to a UI fix

4.2.2 Writing a test-case log for your final report

Simply writing "We tested the system and it worked" loses marks in evaluation. Document a structured test-case table showing test ID, test level, input/action, expected result, actual result, and pass/fail status—and include at least one bug you caught and fixed!

Sample Test-Case Log for a Project Report
Test IDLevelTest Scenario and InputExpected ResultActual ResultStatus
UT-01UnitCall compute_gpa([]) with empty course listRaises ValueError instead of dividing by zeroRaised ValueError("Empty list")Pass
IT-01IntegrationPOST /api/order with quantity exceeding stock (qty=50, stock=12)HTTP 400 error; stock remains 12 in DBHTTP 400 returned; DB unchangedPass
UT-02UnitParse malformed GPS NMEA string without checksumParser returns None and logs warningParser crashed on split -> fixed guard -> returns NonePass (after fix)
UAT-01User8 new users search and download a past paper without helpAll 8 complete task in under 45 s8 of 8 succeeded; average 28 sPass
Example 4.2

Designing unit, integration, and user tests for a clinic queue app

A team builds a local clinic appointment and token-queue web app. Write one unit test, one integration test, and one user testing plan (with acceptance criteria) that the team can execute and include in Chapter 4 of their report.

Unit test (token generator logic): Test next_token(last_token, date_changed):

  • Input ("T-009", False) -> expects "T-010".
  • Input ("T-009", True) (new day reset) -> expects "T-001".
  • Input ("", True) -> expects "T-001".

Run automatically via pytest so edge cases never regress.

Integration test (booking API + database concurrency): Send two concurrent POST /api/book requests for the same doctor and time slot (10:15 AM) using a test client against a temporary SQLite database. Verify that the first request returns HTTP 201 Created with one database row, and the second returns HTTP 409 Conflict without creating a double booking.

User testing plan (validation with clinic staff/volunteers):

Recruit 6 volunteers (3 acting as patients, 3 as receptionists). Ask patients to book a slot and check live queue position, and ask receptionists to call the next token and mark a no-show. Acceptance target: at least 5 of 6 complete all tasks unaided in under 60 seconds, with feedback logged in a short questionnaire.

Answer:

The test plan combines an automated unit test for token formatting and daily reset, a database-backed integration test preventing double bookings, and a 6-user task-based UAT session measuring unaided completion rate and task time.

4.3 Performance evaluation and improvement

Definition

Performance Evaluation

Performance evaluation quantitatively measures how fast, accurate, reliable, or resource-efficient the implemented system is under realistic conditions. Instead of claiming "the system is fast and accurate," evaluation backs every claim with repeatable measurements, compares against a baseline or target objective, and guides targeted improvements.

4.3.1 Choosing the right evaluation metrics

Performance Metrics and Improvement Levers by Project Domain
Project DomainPrimary Metrics to MeasureHow to MeasureCommon Bottleneck and Improvement
Web / Backend / DBMean & 95th-percentile latency (ms), throughput (req/s), query timecurl timing, locust / ab load script, SQL EXPLAIN QUERY PLANMissing DB indexes or N+1 queries -> add indexes, join/paginate queries, cache static responses
AI / ML / VisionAccuracy, Precision, Recall, F1-score, Confusion Matrix, inference time (ms/item)Held-out test set (never train set!), scikit-learn classification report, timer around inferenceClass imbalance, overfitting, slow model -> augment/balance data, tune threshold, use lighter backbone or ONNX
Embedded / IoTSensor error vs reference meter, packet loss (%), alert latency (s), battery current (mA)Compare against calibrated thermometer/multimeter across 20 trials; log sequence numbersNoisy ADC spikes, blocking delay() -> apply moving average/median filter, use non-blocking timers and deep sleep
Mobile / Desktop UIApp startup time, frame smoothness, APK/RAM size, battery drainAndroid Studio profiler or adb memory/startup logsLoading unresized images on main thread -> compress thumbnails, lazy-load lists, run I/O asynchronously

4.3.2 A disciplined improvement loop: measure, profile, optimise, verify

Never optimise blindly from guesswork—often 80% of delay sits in one unexpected function (such as re-loading an ML model on every HTTP request instead of once at server startup). Follow four steps:

  1. Measure the baseline: Record latency, accuracy, or memory on a fixed test input before changing anything.
  2. Profile to locate the bottleneck: Time each stage separately (for example, image decode vs model inference vs database write).
  3. Apply one targeted improvement: Fix the biggest bottleneck first (add an index, resize images once, batch queries, or tune a classifier threshold).
  4. Re-measure and verify correctness: Confirm both that performance improved and that accuracy/functional tests still pass. Keep the before-and-after table for your final report and viva slides!

4.3.3 Interpreting limitations honestly in your final report

Every 1-credit minor project has boundaries—small datasets, lab lighting, single-node hosting, or uncalibrated low-cost sensors. Examiners respect teams that quantify limitations honestly (for example, "Accuracy drops from 92% indoors to 76% under harsh backlighting because our training set had only 300 outdoor images") and propose concrete, realistic future work tied directly to those measurements.

Example 4.3

Evaluating and optimising an image-classification API endpoint

A team builds a plant-leaf disease classifier served via FastAPI. On a held-out test set of 100 images (55 positive diseased, 45 healthy), the model predicts 45 true positives, 5 false positives, 10 false negatives, and 40 true negatives. Profiling shows each API request takes 980 ms: 840 ms to load the PyTorch weights from disk on every call, 110 ms for CPU inference, and 30 ms for image resizing.

  1. Compute the precision, recall, and F1-score for the diseased class.
  2. Propose the single highest-impact latency optimisation and compute the percentage latency reduction if loading time drops to 0 ms per request (keeping 110 ms inference + 5 ms preprocessing).

Evaluate classification metrics on the held-out test set:

  • Precision = TP / (TP + FP) = 45 / (45 + 5) = 45 / 50 = 0.90 (90.0%).
  • Recall = TP / (TP + FN) = 45 / (45 + 10) = 45 / 55 = 0.8182 (81.82%).
  • F1-score = 2 x Precision x Recall / (Precision + Recall) = 2 x 0.90 x 0.8182 / (0.90 + 0.8182) = 1.4728 / 1.7182 = 0.8571 (85.71%).

Identify and fix the primary latency bottleneck:

Load the model weights once at FastAPI server startup and reuse the in-memory model object across all requests, and use faster in-memory resizing (5 ms).

Re-measure and verify the improvement: New per-request latency = 0 + 110 + 5 = 115 ms (down from 980 ms). Percentage latency reduction = (980 - 115) / 980 x 100 = 865 / 980 x 100 = 88.27%.

Answer:

The model achieves 90.0% precision, 81.82% recall, and 85.71% F1-score. Loading the model once at server startup instead of per request cuts latency from 980 ms to 115 ms—an 88.27% reduction—while preserving identical prediction accuracy.

Practice Exercises: Implementation and Testing

Question 1

Distinguish between verification and validation in the context of a minor project. Give one example of each for an online exam proctoring or attendance system.

Verification ("building the system right"): Checking through unit and integration tests that modules satisfy their technical specification—for example, verifying that the attendance API rejects duplicate submissions within the same lecture slot and returns HTTP 409.

Validation ("building the right system"): Checking through user testing and real-world evaluation that the system satisfies user needs and project objectives—for example, running live classroom tests with 30 students and confirming lecturers can record accurate attendance faster than paper roll-call.

Answer:

Verification confirms modules obey technical specifications (e.g., API duplicate-submission unit/integration tests), whereas validation confirms the completed system solves the real user problem (e.g., live classroom trials showing faster, accurate attendance).

Question 2

During your final project viva, an examiner asks: "Your unit tests all passed, so why did your system still crash during live integration?" Explain how unit testing and integration testing differ and what bugs only integration testing catches.

Why unit tests miss integration bugs: Unit tests isolate single functions using mocked inputs and simulated dependencies, so they assume external modules return data in the expected format and timing.

What integration testing catches: Integration testing runs connected components together (such as frontend -> REST API -> database, or microcontroller -> Wi-Fi -> server) and exposes mismatched JSON key names, database constraint/foreign-key errors, environment variable issues, authentication header bugs, and network timeouts.

Answer:

Unit tests verify isolated functions with mocks, whereas integration tests verify real interactions between modules. Mismatched API contracts, database schema/foreign-key violations, serial/network timeouts, and configuration errors appear only when real modules are connected together.

Question 3

How should a student team conduct User Acceptance Testing (UAT) for a minor project, and what evidence should be presented in the final report?

Execution method: Select 5 to 15 representative end users (not the developers themselves), give them realistic task scenarios without guiding their clicks, and measure task completion rate, completion time, and errors or confusion points.

Evidence for the report: Include the task list, summary metrics (for example, percentage of tasks completed unaided and average time), user feedback highlights, and at least one UI or workflow improvement made as a direct result of testing.

Answer:

Conduct UAT by giving realistic, unguided tasks to 5-15 target users, measuring completion rate, time, and errors, and documenting the quantitative summary alongside concrete UI/workflow fixes made from their feedback.

Question 4

In a spam-SMS classifier minor project evaluated on a test set, the confusion matrix gives TP = 85, FP = 15, FN = 25, TN = 175. Compute accuracy, precision, recall, and F1-score for the spam class, and explain why accuracy alone can mislead an examiner on imbalanced datasets.

Total samples and accuracy: Total = 85 + 15 + 25 + 175 = 300. Accuracy = (TP + TN) / Total = (85 + 175) / 300 = 260 / 300 = 0.8667 (86.67%).

Precision, recall, and F1-score: Precision = 85 / (85 + 15) = 85 / 100 = 0.85 (85.0%). Recall = 85 / (85 + 25) = 85 / 110 = 0.7727 (77.27%). F1-score = 2 x 0.85 x 0.7727 / (0.85 + 0.7727) = 1.3136 / 1.6227 = 0.8095 (80.95%).

Why accuracy alone misleads: If 95% of messages are non-spam, a trivial model that predicts "not spam" for everything still achieves 95% accuracy while catching zero spam (0% recall). Precision, recall, and F1-score reveal how well the minority target class is actually detected.

Answer:

Accuracy = 86.67%, Precision = 85.0%, Recall = 77.27%, and F1-score = 80.95%. Accuracy alone is misleading on imbalanced classes because a model can score high accuracy by always predicting the majority class while failing completely on the target class.

Question 5

A student dashboard query taking 420 ms drops to 35 ms after adding a composite database index on (user_id, created_at). Calculate the speedup factor and percentage reduction in query time, and list three practical tips to ensure a smooth final project presentation and defence.

Compute speedup and percentage reduction: Speedup factor = 420 / 35 = 12.0x faster. Percentage reduction = (420 - 35) / 420 x 100 = 385 / 420 x 100 = 91.67%.

Practical defence and presentation tips:

  1. Freeze code 2-3 days before defence and rehearse a clean local + backup-video demo so network drops cannot derail the presentation.
  2. Keep slides visual (architecture diagram, screenshots, test-case log, before/after performance chart) rather than dense paragraphs.
  3. Ensure every team member knows the full system workflow and can explain their own code and limitations honestly during individual viva questions.
Answer:

Adding the index makes the query 12.0x faster (a 91.67% latency reduction). For a smooth defence: freeze and rehearse with a local/video backup, use visual slides with real test/benchmark evidence, and prepare every member to explain both their module and the overall architecture.

← Design, Development and Project Management