<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Artur</title>
    <description>The latest articles on DEV Community by Artur (@arturmkr).</description>
    <link>https://dev.to/arturmkr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F984213%2F355500d0-ff42-4f00-bf7c-930de5d73f57.jpeg</url>
      <title>DEV Community: Artur</title>
      <link>https://dev.to/arturmkr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arturmkr"/>
    <language>en</language>
    <item>
      <title>Checking a Helm Chart Refactor with Manifest Diff</title>
      <dc:creator>Artur</dc:creator>
      <pubDate>Thu, 12 Mar 2026 16:06:58 +0000</pubDate>
      <link>https://dev.to/arturmkr/checking-a-helm-chart-refactor-with-manifest-diff-1l4f</link>
      <guid>https://dev.to/arturmkr/checking-a-helm-chart-refactor-with-manifest-diff-1l4f</guid>
      <description>&lt;p&gt;Sometimes you refactor Helm charts: move logic, simplify templates, merge files or clean up loops and functions.&lt;/p&gt;

&lt;p&gt;The goal of refactoring is not to change the final Kubernetes manifests.&lt;/p&gt;

&lt;p&gt;A simple way to verify this is to render the manifests before and after the change and compare them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic workflow
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 0: Install dependencies&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;yq
brew &lt;span class="nb"&gt;install &lt;/span&gt;dyff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;yq&lt;/strong&gt; - will be used to sort Kubernetes manifests.&lt;br&gt;
&lt;strong&gt;dyff&lt;/strong&gt; - will be used to compare YAML files, highlights real configuration changes and ignores formatting differences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Render manifests before changes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm template my-release ./chart &lt;span class="nt"&gt;-f&lt;/span&gt; values.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; before.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Refactor the Helm chart&lt;/strong&gt;&lt;br&gt;
Change templates, refactor logic, reorganize files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Render manifests again&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm template my-release ./chart &lt;span class="nt"&gt;-f&lt;/span&gt; values.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; after.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Sort manifests (to avoid noise from ordering)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yq &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s1"&gt;'sort_by(.kind, .metadata.name)'&lt;/span&gt; before.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; before_sorted.yaml
yq &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s1"&gt;'sort_by(.kind, .metadata.name)'&lt;/span&gt; after.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; after_sorted.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sorting prevents differences caused only by resource order changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Compare manifests&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dyff between before_sorted.yaml after_sorted.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6bhbv8sosso896orvlvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6bhbv8sosso896orvlvd.png" alt="helm chart difference" width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;If no differences are reported, your refactor did not change the resulting Kubernetes manifests, which means the refactor is safe.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>How to Measure Code Coverage in a Running Java Application Using JaCoCo</title>
      <dc:creator>Artur</dc:creator>
      <pubDate>Mon, 16 Sep 2024 08:45:17 +0000</pubDate>
      <link>https://dev.to/arturmkr/how-to-measure-code-coverage-in-a-running-java-application-using-jacoco-5b13</link>
      <guid>https://dev.to/arturmkr/how-to-measure-code-coverage-in-a-running-java-application-using-jacoco-5b13</guid>
      <description>&lt;p&gt;When developing software, it’s crucial to know how much of your codebase is covered by tests. This article will walk you through using the JaCoCo (Java Code Coverage) tool to measure code coverage in a running Java application. We’ll explore how JaCoCo helps find gaps in coverage and ensures you're not missing critical parts of your application that need testing.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is Code Coverage?
&lt;/h3&gt;

&lt;p&gt;Code coverage is a metric that determines what percentage of your code is being executed by tests. While it doesn't tell you if your tests are well-written, it shows which parts of your code haven't been tested. Low coverage means there are areas of the code that haven’t been executed, and these areas may require more attention. However, even with 100% coverage, your tests might still miss important logic or edge cases. Code coverage simply shows that certain lines of code have been executed at least once during testing.&lt;/p&gt;

&lt;p&gt;Code coverage helps find blind spots in testing, especially in large codebases or when tests are written after the application is already developed.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Use JaCoCo for Code Coverage?
&lt;/h3&gt;

&lt;p&gt;JaCoCo is one of the most popular code coverage tools for Java applications. It works by instrumenting the bytecode of your application at runtime, allowing you to gather coverage data while your application is running, even in production environments. JaCoCo supports both unit tests and functional tests.&lt;/p&gt;

&lt;p&gt;Using JaCoCo in a live environment measures which parts of your code are executed as users interact with your application. This is particularly useful for seeing how well your functional or integration tests cover the actual business logic during runtime.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why This Approach Is Not a Replacement for Traditional Test Management
&lt;/h3&gt;

&lt;p&gt;It’s important to note that code coverage is not a replacement for a traceability matrix or other test management techniques. A traceability matrix ensures that all requirements and scenarios are covered, while code coverage only identifies the parts of your code that haven’t been executed by tests.&lt;/p&gt;

&lt;p&gt;Although code coverage helps identify gaps, having 100% coverage doesn’t guarantee that all scenarios are tested or that your application is free of defects. Zero coverage, however, indicates that specific parts of the code were not tested and need immediate attention.&lt;/p&gt;




&lt;h3&gt;
  
  
  Using JaCoCo to Measure Code Coverage at Runtime
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Note: This approach is particularly useful for measuring code coverage during functional or integration testing, rather than unit testing, as it tracks code executed during real interactions with the application.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Download JaCoCo Tools
&lt;/h4&gt;

&lt;p&gt;Before you start, you'll need to download JaCoCo tools.&lt;/p&gt;

&lt;p&gt;To download the required JaCoCo tools, run the following &lt;code&gt;curl&lt;/code&gt; commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.12/org.jacoco.cli-0.8.12-nodeps.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2: Start Your Java Application with JaCoCo
&lt;/h4&gt;

&lt;p&gt;To instrument your Java application with JaCoCo, you need to start the application with the JaCoCo agent. This agent monitors and records the coverage while the application is running. Here's how to start your application with JaCoCo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java &lt;span class="s1"&gt;'-javaagent:org.jacoco.agent-0.8.12-runtime.jar=port=6300,address=0.0.0.0,destfile=jacoco.exec,includes=com.example.*,append=true,output=tcpserver'&lt;/span&gt; &lt;span class="nt"&gt;-jar&lt;/span&gt; build/libs/demo_api_server-0.0.1-SNAPSHOT.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Breaking Down the Command:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-javaagent&lt;/code&gt;: Tells the JVM to run JaCoCo as an agent alongside your application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;org.jacoco.agent-0.8.12-runtime.jar&lt;/code&gt;: The path to the JaCoCo agent.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;port=6300&lt;/code&gt;: JaCoCo listens on port 6300 for requests to dump coverage data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;address=0.0.0.0&lt;/code&gt;: Sets the address that the JaCoCo agent will bind to.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;destfile=jacoco.exec&lt;/code&gt;: Specifies the file where coverage data will be stored.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;includes=com.example.*&lt;/code&gt;: Limits coverage to specific packages (in this case, &lt;code&gt;com.example.*&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;append=true&lt;/code&gt;: Appends new coverage data to the existing file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;output=tcpserver&lt;/code&gt;: Specifies that JaCoCo will be available via a TCP server, allowing you to dump coverage data on demand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 3: Dump the Coverage Data
&lt;/h4&gt;

&lt;p&gt;Once your application is running and you’ve executed the desired test scenarios (manually or automatically), you can trigger JaCoCo to dump the coverage data. This is particularly useful in production or staging environments where you don't want to shut down the application.&lt;/p&gt;

&lt;p&gt;Use the following command to dump the coverage data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java &lt;span class="nt"&gt;-jar&lt;/span&gt; org.jacoco.cli-0.8.12-nodeps.jar dump &lt;span class="nt"&gt;--address&lt;/span&gt; localhost &lt;span class="nt"&gt;--port&lt;/span&gt; 6300 &lt;span class="nt"&gt;--destfile&lt;/span&gt; jacoco.exec &lt;span class="nt"&gt;--reset&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dump&lt;/code&gt;: Extracts the coverage data from the running JVM.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--address localhost&lt;/code&gt;: The address where JaCoCo is listening.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--port 6300&lt;/code&gt;: The port where JaCoCo is serving coverage data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--destfile jacoco.exec&lt;/code&gt;: The file where the dumped data will be saved.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--reset&lt;/code&gt;: Clears the coverage data after dumping it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 4: Generate the Coverage Report
&lt;/h4&gt;

&lt;p&gt;After dumping the coverage data, generate the coverage report using JaCoCo’s CLI tool. Here’s how to create an HTML report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java &lt;span class="nt"&gt;-jar&lt;/span&gt; org.jacoco.cli-0.8.12-nodeps.jar report jacoco.exec &lt;span class="nt"&gt;--classfiles&lt;/span&gt; build/classes/java/main &lt;span class="nt"&gt;--sourcefiles&lt;/span&gt; src/main/java &lt;span class="nt"&gt;--html&lt;/span&gt; coverage_report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will generate an HTML report showing which parts of the code were executed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5: Analyze the Results
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyv2ewzpiueg4sehna5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyv2ewzpiueg4sehna5l.png" alt="Image description" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have the coverage report, examine areas with zero coverage and identify testing gaps. Keep in mind that high coverage doesn’t guarantee good tests, but no coverage indicates missing tests that need immediate attention.&lt;/p&gt;

&lt;p&gt;You can integrate JaCoCo reports into your CI pipeline (e.g., Jenkins, GitLab CI, GitHub Actions) to track code coverage over time.&lt;/p&gt;




&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code coverage&lt;/strong&gt; measures how much of your code is executed by tests, but it doesn’t guarantee test quality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JaCoCo&lt;/strong&gt; is an easy-to-use tool to measure runtime code coverage, especially useful for identifying gaps in functional or manual testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code coverage and traceability matrix&lt;/strong&gt; serve different purposes: the former highlights executed code, while the latter ensures test scenarios align with requirements.&lt;/li&gt;
&lt;li&gt;For large projects, tools like JaCoCo help quickly identify untested areas, but they should be combined with other testing practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following the steps outlined in this article, you can effectively measure and analyze code coverage in your Java application, ensuring that critical parts of your code are tested.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo code
&lt;/h3&gt;

&lt;p&gt;You can find the complete demo code for measuring code coverage using JaCoCo here:&lt;br&gt;
&lt;a href="https://github.com/arturmkr/jacoco-code-coverage-demo" rel="noopener noreferrer"&gt;https://github.com/arturmkr/jacoco-code-coverage-demo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>codecoverage</category>
      <category>java</category>
    </item>
  </channel>
</rss>
