<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Testing on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/tags/testing/</link><description>Recent content in Testing on Ghafoor's Personal Blog</description><generator>Hugo</generator><language>en</language><managingEditor>noreply@example.com (AG Sayyed)</managingEditor><webMaster>noreply@example.com (AG Sayyed)</webMaster><copyright>Copyright © 2024-2026 AG Sayyed. All Rights Reserved.</copyright><lastBuildDate>Sat, 16 May 2026 17:42:12 +0100</lastBuildDate><atom:link href="http://ghafoorsblog.com/tags/testing/index.xml" rel="self" type="application/rss+xml"/><item><title>Debug With Assert</title><link>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/04-module/003-debug-with-assert/</link><pubDate>Thu, 13 Nov 2025 13:46:44 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/04-module/003-debug-with-assert/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores debugging Python programs using assert statements as sanity checks to catch bugs early in development. Assertions validate assumptions, check preconditions, verify intermediate states, and provide clear error messages when conditions fail, enabling proactive bug detection throughout the coding process.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;A developer&amp;rsquo;s worst nightmare is spending hours developing code only to discover multiple bugs right before deployment. Instead of waiting until the last minute to check code correctness, developers should test and validate throughout the development process. Assert statements provide a mechanism for these continuous sanity checks.&lt;/p&gt;</description></item><item><title>Working with Someone Else's Code</title><link>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/03-module/010-someone-else-code/</link><pubDate>Thu, 13 Nov 2025 12:09:21 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/03-module/010-someone-else-code/</guid><description>&lt;p class="lead text-primary"&gt;
This document provides strategies for understanding and fixing problems in code written by others, covering techniques for reading unfamiliar code, leveraging comments and tests, navigating large codebases, and building skills through practice with open-source projects.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In IT roles, fixing problems in code written by others is a common task. Whether working with open-source software or internal company projects, understanding unfamiliar code requires specific strategies and approaches. Developing these skills enables effective troubleshooting and maintenance of codebases regardless of original authorship.&lt;/p&gt;</description></item><item><title>Component Testing</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/005-component-testing/</link><pubDate>Tue, 29 Jul 2025 08:30:45 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/005-component-testing/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the fundamentals of testing React components, including the advantages and disadvantages, testing approaches, Arrange-Act-Assert pattern, and popular tools like Jest and React Testing Library.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-component-testing"&gt;Introduction to Component Testing&lt;/h2&gt;
&lt;p&gt;Testing is the process of reviewing how code executes, either line-by-line or through suites that verify application behavior. It ensures that applications work as intended and helps prevent regressions.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="advantages-and-disadvantages-of-testing"&gt;Advantages and Disadvantages of Testing&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prevents unexpected regressions&lt;/li&gt;
&lt;li&gt;Allows developers to focus on current tasks&lt;/li&gt;
&lt;li&gt;Enables modular construction of complex applications&lt;/li&gt;
&lt;li&gt;Reduces the need for manual verification&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Web Application</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/01-module/002-web-application/</link><pubDate>Fri, 25 Jul 2025 15:25:41 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/01-module/002-web-application/</guid><description>&lt;p class="lead text-primary"&gt;
This document details the seven phases of the application development lifecycle, including requirements gathering, analysis, design, coding, testing, production, and maintenance. It also explains the importance of organizing code into multiple files for efficient development and maintenance.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="application-development-lifecycle"&gt;Application Development Lifecycle&lt;/h2&gt;
&lt;p&gt;The application development lifecycle is a structured process that guides the creation of software from initial concept to ongoing maintenance. Each phase ensures the application meets user, business, and technical needs while remaining reliable and maintainable.&lt;/p&gt;</description></item><item><title>Why don't Developers want to test?</title><link>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/01-module/003-why-to-test/</link><pubDate>Mon, 21 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/01-module/003-why-to-test/</guid><description>&lt;p class="lead text-primary"&gt;
This module examines why developers often avoid writing tests, the consequences of skipping testing, and how a strong test suite supports future development, code safety, and collaboration in open source and enterprise environments.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Testing is frequently neglected by developers for reasons such as overconfidence in their code, lack of time, or the belief that testing is unnecessary. However, skipping tests can lead to undetected bugs, compatibility issues, and future maintenance challenges.&lt;/p&gt;</description></item><item><title>Testing Guide</title><link>http://ghafoorsblog.com/docs/anki/testing_guide/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/docs/anki/testing_guide/</guid><description>&lt;h1 id="scss-styling-system---complete-testing-guide"&gt;SCSS Styling System - Complete Testing Guide&lt;/h1&gt;
&lt;h1 id="this-script-shows-you-exactly-how-to-test-the-styling-integration"&gt;This script shows you exactly how to test the styling integration&lt;/h1&gt;
&lt;p&gt;cat &amp;laquo; &amp;lsquo;EOF&amp;rsquo;&lt;/p&gt;
&lt;p&gt;╔═══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ SCSS STYLING SYSTEM - COMPLETE TESTING GUIDE ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════════╝&lt;/p&gt;
&lt;p&gt;📋 TESTING LEVELS
═══════════════════════════════════════════════════════════════════════════════&lt;/p&gt;
&lt;p&gt;Level 1: Unit Testing (Automated)
✓ Verify CSS files exist and compile
✓ Test CSS caching mechanism
✓ Test course detection from metadata
✓ Run: npm run test:anki&lt;/p&gt;
&lt;p&gt;Level 2: Integration Testing (Automated + Manual)
✓ Generate test APKGs with CSS
✓ Verify CSS embedded in APKG
✓ Test course-specific vs default CSS
✓ Run: npm run test:anki:verbose&lt;/p&gt;</description></item><item><title>Testing Quick Reference</title><link>http://ghafoorsblog.com/docs/anki/testing_quick_reference/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/docs/anki/testing_quick_reference/</guid><description>&lt;h1 id="scss-styling-system---quick-reference-guide"&gt;SCSS Styling System - Quick Reference Guide&lt;/h1&gt;
&lt;h2 id="-quick-start-testing-5-minutes"&gt;🚀 Quick Start Testing (5 minutes)&lt;/h2&gt;
&lt;h3 id="1-verify-tests-pass"&gt;1. Verify Tests Pass&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;npm run test:anki
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;✅ Expected: 52 tests passing&lt;/p&gt;
&lt;h3 id="2-verify-css-files-exist"&gt;2. Verify CSS Files Exist&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;npm run anki:styles:list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;✅ Expected: psychology.css (16 KB), devops.css (17 KB)&lt;/p&gt;
&lt;h3 id="3-generate-test-apkg-from-real-data"&gt;3. Generate Test APKG from Real Data&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 1&lt;/span&gt;&lt;span class="cl"&gt;conda activate ags-anki
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 2&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 3&lt;/span&gt;&lt;span class="cl"&gt;python3 &lt;span class="s"&gt;&amp;lt;&amp;lt; &amp;#39;PYTHON&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;import json
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;from pathlib import Path
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 6&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;from scripts.anki.apkg_generator import APKGGenerator
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 7&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;import tempfile, shutil
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 8&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 9&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;# Load real psychology data
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;10&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;with open(&amp;#34;data/course/psychology-l2/01/01m/001/anki/01-counselling-skills.json&amp;#34;) as f:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;11&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; data = json.load(f)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;12&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;13&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;# Ensure course metadata exists
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;14&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;if &amp;#39;course&amp;#39; not in data[&amp;#39;metadata&amp;#39;]:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;15&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; data[&amp;#39;metadata&amp;#39;][&amp;#39;course&amp;#39;] = &amp;#39;psychology&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;16&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;17&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;# Generate APKG with styling
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;18&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;with tempfile.TemporaryDirectory() as tmpdir:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;19&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; gen = APKGGenerator(verbose=True)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;20&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; apkg = gen.generate_from_data(data, tmpdir, data[&amp;#39;metadata&amp;#39;].get(&amp;#39;deck_name&amp;#39;))
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;21&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;22&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; # Copy to Desktop
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;23&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; shutil.copy(apkg, Path.home() / &amp;#34;Desktop&amp;#34; / &amp;#34;psychology-real-data.apkg&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;24&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; print(f\n✅ APKG copied to ~/Desktop/psychology-real-data.apkg&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;25&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;26&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt; print(f&amp;#34; Size: {apkg.stat().st_size / 1024:.1f} KB (includes psychology CSS)&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;27&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="s"&gt;PYTHON&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;✅ Expected:&lt;/p&gt;</description></item><item><title>Testing Verification</title><link>http://ghafoorsblog.com/docs/anki/testing_verification/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/docs/anki/testing_verification/</guid><description>&lt;h1 id="testing-verification-placeholder"&gt;testing verification placeholder&lt;/h1&gt;
&lt;p&gt;#!/bin/bash&lt;/p&gt;
&lt;h1 id="quick-test-to-verify-css-is-in-apkg-sqlite-database"&gt;Quick test to verify CSS is in APKG SQLite database&lt;/h1&gt;
&lt;p&gt;cat &amp;laquo; &amp;lsquo;EOF&amp;rsquo;&lt;/p&gt;
&lt;p&gt;╔═══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ HOW TO VERIFY CSS IS EMBEDDED IN YOUR APKG FILES ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════════╝&lt;/p&gt;
&lt;p&gt;FILES TO TEST WITH
════════════════════════════════════════════════════════════════════════════════&lt;/p&gt;
&lt;p&gt;Run this command to generate test APKGs:&lt;/p&gt;
&lt;p&gt;python3 &amp;laquo; &amp;lsquo;PYTHON&amp;rsquo;
import json
import tempfile
from pathlib import Path
from scripts.anki.apkg_generator import APKGGenerator&lt;/p&gt;
&lt;h1 id="psychology-apkg"&gt;Psychology APKG&lt;/h1&gt;
&lt;p&gt;psy_data = {
&amp;ldquo;metadata&amp;rdquo;: {&amp;ldquo;course&amp;rdquo;: &amp;ldquo;psychology&amp;rdquo;, &amp;ldquo;deck_name&amp;rdquo;: &amp;ldquo;Psy-Test&amp;rdquo;, &amp;ldquo;unit&amp;rdquo;: &amp;ldquo;U1&amp;rdquo;, &amp;ldquo;module&amp;rdquo;: &amp;ldquo;M1&amp;rdquo;},
&amp;ldquo;flashcards&amp;rdquo;: [{&amp;ldquo;id&amp;rdquo;: &amp;ldquo;1&amp;rdquo;, &amp;ldquo;question&amp;rdquo;: &amp;ldquo;Q?&amp;rdquo;, &amp;ldquo;answer&amp;rdquo;: &amp;ldquo;A&amp;rdquo;, &amp;ldquo;tags&amp;rdquo;: [&amp;ldquo;test&amp;rdquo;], &amp;ldquo;difficulty&amp;rdquo;: 1}]
}&lt;/p&gt;</description></item></channel></rss>