<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Testing Archives - Rhein-Ruhr-Informatik</title>
	<atom:link href="https://rhein-ruhr-informatik.de/en/category/articles/testing/feed/" rel="self" type="application/rss+xml" />
	<link>https://rhein-ruhr-informatik.de/en/category/articles/testing/</link>
	<description></description>
	<lastbuilddate>Tue, 13 May 2025 12:03:16 +0000</lastbuilddate>
	<language>en-US</language>
	<sy:updateperiod>
	hourly	</sy:updateperiod>
	<sy:updatefrequency>
	1	</sy:updatefrequency>
	

<image>
	<url>https://rhein-ruhr-informatik.de/wp-content/uploads/2025/03/cropped-favicon-32x32.png</url>
	<title>Testing Archives - Rhein-Ruhr-Informatik</title>
	<link>https://rhein-ruhr-informatik.de/en/category/articles/testing/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Test Coverage mit Jasmine und Karma in 3 einfachen Schritten</title>
		<link>https://rhein-ruhr-informatik.de/en/2025/06/16/test-coverage-mit-jasmine-und-karma-in-3-einfachen-schritten/</link>
		
		<dc:creator><![CDATA[Rhein-Ruhr-Informatik]]></dc:creator>
		<pubdate>Mon, 16 Jun 2025 05:33:10 +0000</pubdate>
				<category><![CDATA[Artikel]]></category>
		<category><![CDATA[Testing]]></category>
		<guid ispermalink="false">https://rhein-ruhr-informatik.de/?p=810</guid>

					<description><![CDATA[<p>In this tutorial, we will learn how to set up test coverage in a project using Jasmine<br />
and how to measure unit tests. Test coverage is a metric that indicates how much of<br />
your code is covered by unit tests. Good coverage helps identify untested parts and<a class="moretag" href="https://rhein-ruhr-informatik.de/en/2025/06/16/test-coverage-mit-jasmine-und-karma-in-3-einfachen-schritten/"> Read more&#8230;</a></p>
<p>The post <a href="https://rhein-ruhr-informatik.de/en/2025/06/16/test-coverage-mit-jasmine-und-karma-in-3-einfachen-schritten/">Test Coverage mit Jasmine und Karma in 3 einfachen Schritten</a> appeared first on <a href="https://rhein-ruhr-informatik.de/en">Rhein-Ruhr-Informatik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this tutorial, we will learn how to set up test coverage in a project using Jasmine
and how to measure unit tests. Test coverage is a metric that indicates how much of
your code is covered by unit tests. Good coverage helps identify untested parts and
improves software reliability.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<ol class="wp-block-list">
<li>Node.js must be installed on your computer.</li>



<li>Jasmine is already set up in the project.</li>



<li>Basic knowledge of unit testing.</li>
</ol>



<h2 class="wp-block-heading">Step 1: Configure Karma with Test Coverage</h2>



<p>Jasmine alone does not generate test coverage, but we can integrate the
karma-coverage plugin with Karma for this purpose.</p>



<p><strong>Install the required dependencies:</strong></p>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" width="982" height="60" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-7.png" alt="" class="wp-image-812" style="width:531px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-7.png 982w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-7-300x18.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-7-768x47.png 768w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-7-18x1.png 18w" sizes="(max-width: 982px) 100vw, 982px" /></figure>



<ul class="wp-block-list">
<li>Update Karma’s configuration file (karma.conf.js) to use the karma-coverage plugin</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="588" height="552" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-8.png" alt="" class="wp-image-813" style="width:362px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-8.png 588w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-8-300x282.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-8-13x12.png 13w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<ul class="wp-block-list">
<li>Key Notes:<br>○ preprocessors: Specifies that files in the src/ directory should be processed
to measure test coverage.<br>○ coverageReporter: Configures the report type (HTML here) and the output
directory for the coverage report.</li>
</ul>



<p><strong>Run the tests with Karma:</strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="317" height="56" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-9.png" alt="" class="wp-image-814" style="width:213px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-9.png 317w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-9-300x53.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-9-18x3.png 18w" sizes="(max-width: 317px) 100vw, 317px" /></figure>



<ul start="4" class="wp-block-list">
<li>After execution, the coverage reports will be available in the coverage/ directory.</li>
</ul>



<h2 class="wp-block-heading">Step 2: Analyze the Reports</h2>



<p>Open the <code>coverage/index.html</code> file in a browser to view the following details:</p>



<p>● Statements: Percentage of covered code statements.<br>● Branches: Percentage of covered code branches (e.g., if and else paths).<br>● Functions: Percentage of tested functions.<br>● Lines: Percentage of covered code lines.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="244" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10-1024x244.png" alt="" class="wp-image-815" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10-1024x244.png 1024w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10-300x71.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10-768x183.png 768w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10-18x4.png 18w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-10.png 1118w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Step 3: Improving Coverage</h2>



<p>● Write additional tests to cover untested scenarios.<br>● Focus on critical areas, such as functions with complex logic.<br>● Use the metrics from the reports to prioritize testing for important code sections.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>With this, you have set up an efficient coverage analysis using Jasmine and Karma. Now
you know where to improve your code, which not only enhances quality but also helps detect
potential bugs before they reach users. I hope this short tutorial was helpful. Now let’s code!
🚀</p><p>The post <a href="https://rhein-ruhr-informatik.de/en/2025/06/16/test-coverage-mit-jasmine-und-karma-in-3-einfachen-schritten/">Test Coverage mit Jasmine und Karma in 3 einfachen Schritten</a> appeared first on <a href="https://rhein-ruhr-informatik.de/en">Rhein-Ruhr-Informatik</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Einstieg in Unit-Tests mit JavaScript, Jasmine und Karma</title>
		<link>https://rhein-ruhr-informatik.de/en/2025/05/30/einstieg-in-unit-tests-mit-javascript-jasmine-und-karma/</link>
		
		<dc:creator><![CDATA[Rhein-Ruhr-Informatik]]></dc:creator>
		<pubdate>Fri, 30 May 2025 05:58:10 +0000</pubdate>
				<category><![CDATA[Artikel]]></category>
		<category><![CDATA[Testing]]></category>
		<guid ispermalink="false">https://rhein-ruhr-informatik.de/?p=800</guid>

					<description><![CDATA[<p>Learn how to build reliable JavaScript applications through unit testing! In this hands-on tutorial, you’ll set up Jasmine and Karma from scratch, write meaningful tests for your code, and automate test execution. Whether you’re new to testing or refining your skills, this guide will equip you with foundational practices to ensure clean, maintainable code.<a class="moretag" href="https://rhein-ruhr-informatik.de/en/2025/05/30/einstieg-in-unit-tests-mit-javascript-jasmine-und-karma/"> Read more&#8230;</a></p>
<p>The post <a href="https://rhein-ruhr-informatik.de/en/2025/05/30/einstieg-in-unit-tests-mit-javascript-jasmine-und-karma/">Einstieg in Unit-Tests mit JavaScript, Jasmine und Karma</a> appeared first on <a href="https://rhein-ruhr-informatik.de/en">Rhein-Ruhr-Informatik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Learn how to build reliable JavaScript applications through unit testing! In this hands-on tutorial, you’ll set up Jasmine and Karma from scratch, write meaningful tests for your code, and automate test execution. Whether you’re new to testing or refining your skills, this guide will equip you with foundational practices to ensure clean, maintainable code. Let’s turn messy code into trustworthy solutions!</p>



<h3 class="wp-block-heading"><strong>1.</strong><strong> </strong><strong>Prerequisites</strong></h3>



<ul class="wp-block-list">
<li>Code editor of your choice</li>



<li>Code-Editor Ihrer Wahl</li>
</ul>



<h3 class="wp-block-heading"><a></a><strong>2.</strong><strong> </strong><strong>Install Dependencies</strong></h3>



<p>This step establishes the testing ecosystem. Jasmine provides the testing syntax and assertion capabilities, while Karma acts as the test runner that executes tests in real browsers. The Chrome launcher enables testing in a familiar browser environment.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="923" height="298" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image.png" alt="" class="wp-image-802" style="width:568px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image.png 923w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-300x97.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-768x248.png 768w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-18x6.png 18w" sizes="auto, (max-width: 923px) 100vw, 923px" /></figure>



<h3 class="wp-block-heading"><a></a><strong>Configure Karma</strong></h3>



<p>Karma's configuration wizard helps create an optimal test environment. By selecting Jasmine as the testing framework and Chrome as the target browser, you ensure tests run consistently. The file patterns tell Karma where to look for source files and tests.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="306" height="50" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-1.png" alt="" class="wp-image-803" style="width:188px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-1.png 306w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-1-300x49.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-1-18x3.png 18w" sizes="auto, (max-width: 306px) 100vw, 306px" /></figure>



<p><strong>During setup</strong></p>



<ul class="wp-block-list">
<li>Testing framework: Jasmine</li>



<li>Browser: Chrome</li>



<li>File paths <code>src/*.js, test/*.spec.js</code></li>



<li>Keep defaults for other options</li>
</ul>



<h3 class="wp-block-heading"><strong> </strong><strong>Project Structure</strong></h3>



<pre class="wp-block-code"><code>my-test-project/
├── src/
│   └── calculator.js
├── test/
│   └── calculator.spec.js
├── karma.conf.js
└── package.json
</code></pre>



<p>A logical file structure separates concerns between application code (src) and test specifications (test). The .spec.js suffix clearly identifies test files, following JavaScript community conventions. This organization improves code maintainability.</p>



<h3 class="wp-block-heading"><a></a><strong>Sample Code (src/calculator.js)</strong></h3>



<p>So, here is just a code sample that we will use to write unit tests for:</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="331" height="306" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-2.png" alt="" class="wp-image-805" style="width:236px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-2.png 331w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-2-300x277.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-2-13x12.png 13w" sizes="auto, (max-width: 331px) 100vw, 331px" /></figure>



<h3 class="wp-block-heading"><a></a><strong>Test Cases (test/calculator.spec.js)</strong></h3>



<p>Jasmine's human-readable syntax uses describe blocks to group related tests and it statements for individual scenarios. Each expect assertion verifies specific functionality, creating a safety net against regressions.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="661" height="320" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-3.png" alt="" class="wp-image-806" style="width:402px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-3.png 661w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-3-300x145.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-3-18x9.png 18w" sizes="auto, (max-width: 661px) 100vw, 661px" /></figure>



<h3 class="wp-block-heading"><a></a><strong>7. npm-Scripts (package.json)</strong></h3>



<p>Custom scripts in package.json automate test execution. The --single-run mode is ideal for CI/CD pipelines, while watch mode provides instant feedback during development. These shortcuts streamline your testing workflow.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="463" height="130" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-4.png" alt="" class="wp-image-807" style="width:336px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-4.png 463w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-4-300x84.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-4-18x5.png 18w" sizes="auto, (max-width: 463px) 100vw, 463px" /></figure>



<h3 class="wp-block-heading"><a></a><strong>Running Tests</strong></h3>



<p>Test execution validates your code's behavior in real-time. Karma spins up a browser instance, runs all tests, and reports results in the terminal. Green checkmarks confirm your code works as intended, while failures highlight areas needing attention.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="420" height="172" src="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-5.png" alt="" class="wp-image-808" style="width:284px;height:auto" srcset="https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-5.png 420w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-5-300x123.png 300w, https://rhein-ruhr-informatik.de/wp-content/uploads/2025/05/image-5-18x7.png 18w" sizes="auto, (max-width: 420px) 100vw, 420px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p><strong>Universal Tips</strong></p>



<ul class="wp-block-list">
<li>Start with simple test cases</li>



<li>Use <code>describe()</code> for test suites</li>



<li>Each <code>it()</code> represents one test scenario</li>



<li>Common matchers: <code>.toBe(), .toEqual(), .toThrow()</code></li>



<li>Debug with <code>console.log()</code> in tests if needed</li>
</ul>



<p><strong>Now, happy testing!</strong> 🚀</p><p>The post <a href="https://rhein-ruhr-informatik.de/en/2025/05/30/einstieg-in-unit-tests-mit-javascript-jasmine-und-karma/">Einstieg in Unit-Tests mit JavaScript, Jasmine und Karma</a> appeared first on <a href="https://rhein-ruhr-informatik.de/en">Rhein-Ruhr-Informatik</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>