<?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>XP Practices - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/category/xp-practices/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Sat, 27 Sep 2025 15:00:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>XP Practices - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to use Visual Studio Live Share &#8211; Paired Programming and Collaboration</title>
		<link>https://thecodebuzz.com/visual-studio-live-share-getting-started/</link>
					<comments>https://thecodebuzz.com/visual-studio-live-share-getting-started/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[XP Practices]]></category>
		<category><![CDATA[how to use live share]]></category>
		<category><![CDATA[live share download]]></category>
		<category><![CDATA[live share vscode not working]]></category>
		<category><![CDATA[Live Share-Collaborate using Visual Studio Code]]></category>
		<category><![CDATA[visual studio live share audio]]></category>
		<category><![CDATA[vscode live share github]]></category>
		<category><![CDATA[vscode live share security]]></category>
		<category><![CDATA[vscode live share server]]></category>
		<category><![CDATA[vscode live share source code]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=3033</guid>

					<description><![CDATA[<p>How to use Visual Studio Live Share -Paired Programming and Collaboration Today in this article, we shall see Visual Studio Live Share features in detail. Recently I happened to try and use Live Share and was stunned by the power of this tool. If I ever opt to choose the best feature or tools recently [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/visual-studio-live-share-getting-started/">How to use Visual Studio Live Share – Paired Programming and Collaboration</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">How to use Visual Studio Live Share -Paired Programming and Collaboration</h1>



<figure class="is-resized wp-block-image"><a href="https://www.thecodebuzz.com/visual-studio-live-share-getting-started/" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" width="1177" height="578" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/image-32.jpg?fit=785%2C386&amp;ssl=1" alt="Paired Programming using liveshare" class="wp-image-3116" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-32.jpg 1177w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-32-300x147.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-32-1024x503.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-32-768x377.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-32-785x385.jpg 785w" sizes="(max-width: 1177px) 100vw, 1177px" /></a></figure>



<p class="">Today in this article, we shall see Visual Studio Live Share features in detail.</p>



<p class=""></p>



<p class="">Recently I happened to try and use Live Share and was stunned by the power of this tool. </p>



<p class=""></p>



<p class="">If I ever opt to choose the best feature or tools recently released by Microsoft, then Live Share would be my first choice undoubtedly.</p>



<p class=""></p>



<p class="">Visual Studio Live Share certainly aims to do away with the traditional practice of sharing the screen via Skype, Slack, or Teams instead of the live interactive code-sharing session. </p>



<p class=""></p>



<p class="">One can share a file or full project context with continuous collaboration bringing Developers, Testers, and Architects together. </p>



<p class=""></p>



<p class="">This is one of the tools that can take <strong>SDLC </strong>to the next level as software industries are leaning towards more lean-agile and <strong>T-shaped</strong> teams. </p>



<p class=""></p>



<p class="">As we are now aware the primary goal of<strong> Live Share</strong> is to enable developers to collaborate easily. </p>



<p class=""></p>



<p class="">There are below additional use cases that Live Share is capable of addressing.</p>



<p class=""></p>



<ul class="wp-block-list">
<li class=""><strong>Paired programming</strong></li>



<li class=""><strong>Continuous Code Review</strong></li>



<li class=""><strong>Interactive Learning/Session</strong></li>



<li class=""><strong>Technical Interviews</strong></li>



<li class=""><strong>+ Many more </strong></li>
</ul>



<p class=""></p>



<p class="">Let&#8217;s get started and follow the step-by-step process to configure live share for Visual Studio Code.</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-prerequisites">Prerequisites</a></li><li><a href="#aioseo-getting-started">Getting Started &#8211; Visual Studio Live Share</a><ul><li><a href="#aioseo-install-visual-studio-code-live-share">Install Visual Studio Code Live Share</a></li></ul></li><li><a href="#aioseo-sharing-project-or-files">Sharing Project or Files</a></li><li><a href="#aioseo-real-time-collaboration-in-vscode-and-vs2019">Real-time Collaboration in VSCode and VS2019</a></li><li><a href="#aioseo-stopping-the-collaboration-session">Stopping the collaboration session</a></li><li><a href="#aioseo-sharing-terminal-windows">Sharing Terminal windows &#8211; Visual Studio Live Share</a></li><li><a href="#aioseo-collaborative-debugging">Collaborative Debugging &#8211; Visual Studio Live Share</a></li><li><a href="#aioseo-highlights">Highlights of Visual Studio Live Share</a></li><li><a href="#aioseo-summary">Summary</a></li></ul></div>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-prerequisites"><strong>Prerequisites</strong></h2>



<p class=""></p>



<ul class="wp-block-list">
<li class=""><strong>IDE &#8211; Visual Studio Code</strong> (1.22 or higher) , <strong>VS2017</strong>(15.6 and above) or <strong>VS2019</strong></li>



<li class=""><strong>OS </strong>&#8211; <strong>Windows </strong>(7,8 or 10) , <strong>macOS</strong>(10.12) , <strong>Linux </strong>(Ubuntu 16.04+, Fedora 27+,CenterOS7)</li>
</ul>



<p class=""></p>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-getting-started">Getting Started &#8211; Visual Studio Live Share</h2>



<p class=""></p>



<h4 class="wp-block-heading" id="aioseo-install-visual-studio-code-live-share"><strong>Install Visual Studio Code Live Share</strong></h4>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Install through VS extension within VS Code.</li>
</ul>



<p class=""></p>



<figure class="is-resized wp-block-image"><img decoding="async" width="1760" height="479" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension.jpg?fit=785%2C214&amp;ssl=1" alt="Paired Programming" class="wp-image-3066" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension.jpg 1760w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension-300x82.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension-1024x279.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension-768x209.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension-1536x418.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-extension-785x214.jpg 785w" sizes="(max-width: 1760px) 100vw, 1760px" /></figure>



<p class=""></p>



<p class="">OR Please install from <a href="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare-pack">Market place</a> </p>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Once installed successfully Live share icon can be seen in the Status Bar and Activity Bar. Please open the project or files to use it for Live share,</li>
</ul>



<p class=""></p>



<figure class="is-resized wp-block-image"><img decoding="async" width="924" height="1185" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1.jpg?fit=785%2C1007&amp;ssl=1" alt="Visual Studio Live Share in Visual studio code" class="wp-image-3069" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1.jpg 924w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1-234x300.jpg 234w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1-798x1024.jpg 798w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1-768x985.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-1-405x520.jpg 405w" sizes="(max-width: 924px) 100vw, 924px" /></figure>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-sharing-project-or-files">Sharing Project or Files</h2>



<p class=""></p>



<p class="">Please click on Live Share in the Status Bar or Activity as shown above. </p>



<p class="">Users will be prompted with the below information message showing the default connection mode used will be &#8220;Auto&#8221;. Please click &#8220;OK&#8221; to proceed.</p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="1722" height="566" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/image-26.png?fit=785%2C258&amp;ssl=1" alt="Activate Visual Studio Live Share" class="wp-image-3073" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-26.png 1722w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-26-300x99.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-26-1024x337.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-26-768x252.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-26-1536x505.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-26-785x258.png 785w" sizes="auto, (max-width: 1722px) 100vw, 1722px" /></figure>



<p class=""></p>



<p class="">An invite link will be copied to your clipboard automatically. </p>



<p class="">Once you start your collaboration session, you can set the session to be read-only to prevent guests from making edits. </p>



<p class="">By default, it will be read-write mode will be enabled the user will be able to edit the code shared in the session.</p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="2320" height="739" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/image-27.png?fit=785%2C250&amp;ssl=1" alt="Visual Studio Live Share in Visual studio code" class="wp-image-3075" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-27.png 2320w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-300x96.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-1024x326.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-768x245.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-1536x489.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-2048x652.png 2048w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-27-785x250.png 785w" sizes="auto, (max-width: 2320px) 100vw, 2320px" /></figure>



<p class=""></p>



<p class="">Let&#8217;s share this link with someone who wants to collaborate. I tried sharing this link to someone who has Visual Studio 2017 or 2019 installed but not VS Code. I found it to be working perfectly fine.</p>



<p class=""></p>



<p class="">Participants joining the shared link need to click on<strong> &#8216;Join collaboration sessions.</strong></p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="1446" height="812" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session.jpg?fit=785%2C441&amp;ssl=1" alt="" class="wp-image-3080" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session.jpg 1446w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-300x168.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-1024x575.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-768x431.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-785x441.jpg 785w" sizes="auto, (max-width: 1446px) 100vw, 1446px" /></figure>



<p class=""></p>



<p class="">Participants enter the invite link within the command pallet windows below</p>



<p class=""></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2267" height="262" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2.jpg?fit=785%2C90&amp;ssl=1" alt="" class="wp-image-3079" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2.jpg 2267w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-300x35.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-1024x118.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-768x89.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-1536x178.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-2048x237.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session2-785x91.jpg 785w" sizes="auto, (max-width: 2267px) 100vw, 2267px" /></figure>



<p class=""></p>



<p class="">Once connected all participants will be visible under the session details as below,</p>



<p class=""></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2026" height="767" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined.jpg?fit=785%2C297&amp;ssl=1" alt="Share screen using Live share" class="wp-image-3081" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined.jpg 2026w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined-300x114.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined-1024x388.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined-768x291.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined-1536x581.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-joined-785x297.jpg 785w" sizes="auto, (max-width: 2026px) 100vw, 2026px" /></figure>



<p class=""></p>



<p class="">Let’s allow 1 more new participant (with VS2019) to collaborate. </p>



<p class="">Please note that the collaboration between the VSCode and VS2019 works perfectly fine.</p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="643" height="902" src="https://www.thecodebuzz.com/wp-content/uploads/2019/05/image-29.png" alt="Live session with Live share" class="wp-image-3093" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-29.png 643w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-29-214x300.png 214w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-29-371x520.png 371w" sizes="auto, (max-width: 643px) 100vw, 643px" /></figure>



<p class=""></p>



<p class="">Participants joining the same meeting invite using <strong>VS2019</strong>.</p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="1617" height="884" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/image-30.png?fit=785%2C429&amp;ssl=1" alt="" class="wp-image-3094" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-30.png 1617w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-30-300x164.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-30-1024x560.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-30-768x420.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-30-1536x840.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-30-785x429.png 785w" sizes="auto, (max-width: 1617px) 100vw, 1617px" /></figure>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-real-time-collaboration-in-vscode-and-vs2019">Real-time Collaboration in VSCode and VS2019  </h2>



<p class=""></p>



<p class="">The below figure shows the real-time Live Share Collaboration in VSCode and VS2019 for the shared codebase.</p>



<p class=""></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="700" height="372" src="https://www.thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-join-session-gif.gif" alt="Visual Studio Live Share in Visual studio code" class="wp-image-3096"/><figcaption class="wp-element-caption">Live Share collaboration in <strong>VSCode </strong>and <strong>VS2019 </strong></figcaption></figure>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-stopping-the-collaboration-session">Stopping the collaboration session</h2>



<p class=""></p>



<p class=""> Stopping the sharing session can be done using the below options,</p>



<p class=""></p>



<figure class="is-resized wp-block-image"><img loading="lazy" decoding="async" width="1107" height="782" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/image-31.jpg?fit=785%2C554&amp;ssl=1" alt="" class="wp-image-3099" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/image-31.jpg 1107w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-31-300x212.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-31-1024x723.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-31-768x543.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/image-31-736x520.jpg 736w" sizes="auto, (max-width: 1107px) 100vw, 1107px" /></figure>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-sharing-terminal-windows">Sharing Terminal windows &#8211; Visual Studio Live Share</h2>



<p class=""></p>



<p class="">Apart from sharing projects or files, Live Share allows you to share your terminal window with other users. The shared terminal can be read-only (default) or read/write thereby allowing full collaboration. </p>



<p class=""></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1236" height="800" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal.jpg?fit=785%2C508&amp;ssl=1" alt="" class="wp-image-3105" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal.jpg 1236w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal-300x194.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal-1024x663.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal-768x497.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/VSLive-share-icon-vscode-share-terminal-785x508.jpg 785w" sizes="auto, (max-width: 1236px) 100vw, 1236px" /></figure>



<p class=""></p>



<p class="">Each participant can run commands on the terminal window, see the results, do Builds, run test cases. </p>



<p class=""></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-1024x576.gif" alt="" class="wp-image-19241" srcset="https://thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-1024x576.gif 1024w, https://thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-300x169.gif 300w, https://thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-768x432.gif 768w, https://thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-1536x864.gif 1536w, https://thecodebuzz.com/wp-content/uploads/2021/11/vscode-live-share-debugging-terminal-window-GIF-785x442.gif 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading" id="aioseo-collaborative-debugging"><br>Collaborative Debugging &#8211; Visual Studio Live Share</h2>



<p class=""></p>



<p class="">Visual Studio Live Share allows a team to follow a collaborative debugging technique to solve any problem/issue. Team members can use this technique for troubleshooting issues by providing a shared debugging session on the host&#8217;s machine.</p>



<p class=""></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1897" height="924" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging.jpg?fit=785%2C383&amp;ssl=1" alt="" class="wp-image-3111" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging.jpg 1897w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging-300x146.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging-1024x499.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging-768x374.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging-1536x748.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/vscode-live-share-debugging-785x382.jpg 785w" sizes="auto, (max-width: 1897px) 100vw, 1897px" /></figure>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-highlights">Highlights of Visual Studio Live Share</h2>



<p class=""></p>



<p class="">Here I have listed a few nice-to-know characteristics of Live Share for your information,</p>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Visual Studio Live Share is <strong>SSH or SSL </strong>encrypted and authenticated.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Live Share allows a user to share the Terminal window with each other. </li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Users can perform remote debugging by sharing the locally hosted server application.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Live Share allows you to share your active debug session, without requiring participants to install any of the necessary platforms <strong>SDKs (e.g. Node.js, Go, .NET Core)</strong> or tooling extensions.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Live Share allows you to share debug state for any programming language or runtime environment (e.g. Kubernetes, React Native app)</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Live Share allows you to share code between different <strong>IDE </strong>like <strong>VSCode </strong>and <strong>Visual </strong>Studio is possible. </li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Embedded JavaScript in HTML is supported when doing client debugging.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">JavaScript / TypeScript debugging for Node or browser is supported.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Currently, the guest limit is up to 30 users. (Please check for any updates on limits)</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Users can join in read-only mode to avoid accidental edits.</li>
</ul>



<p class=""></p>



<ul class="wp-block-list">
<li class="">Live Share allows you to control sensitive file access and visibility if required.</li>
</ul>



<p class=""></p>



<p class=""><strong><em>References</em></strong>:</p>



<p class=""></p>



<ul class="wp-block-list">
<li class=""><a href="https://www.thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/" target="_blank" rel="noopener" title="Visual Studio IntelliCode –  Code Development using AI"><strong><em>Visual Studio IntelliCode –  Code Development using AI</em></strong></a></li>
</ul>



<p class=""></p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p class=""></p>



<h2 class="wp-block-heading" id="aioseo-summary"><strong>Summary</strong></h2>



<p class=""></p>



<p class=""><strong><em>VS Live Share</em></strong> is undoubtedly one of the most recent features from Microsoft. Live share enables developers to collaborate easily and also eases performing extreme programming(XP) practices like paired programming, mob programming, continuous code review, performing Interactive Learnings, conducting brainstorming Sessions, etc&#8230;</p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p> </p><p>The post <a href="https://thecodebuzz.com/visual-studio-live-share-getting-started/">How to use Visual Studio Live Share – Paired Programming and Collaboration</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/visual-studio-live-share-getting-started/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Unit Test and Mock ActionFilter in ASP.NET Core</title>
		<link>https://thecodebuzz.com/unit-test-mock-actionfilter-asp-net-core-actionexecutingcontext-moq/</link>
					<comments>https://thecodebuzz.com/unit-test-mock-actionfilter-asp-net-core-actionexecutingcontext-moq/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 19 Dec 2021 02:16:00 +0000</pubDate>
				<category><![CDATA[XP Practices]]></category>
		<category><![CDATA[.net core unit test mock]]></category>
		<category><![CDATA[asp net core unit test authorization]]></category>
		<category><![CDATA[asp net core unit test dependency injection]]></category>
		<category><![CDATA[asp net core unit testing]]></category>
		<category><![CDATA[asp net core web api unit testing example]]></category>
		<category><![CDATA[resultexecutingcontext unit test]]></category>
		<category><![CDATA[unit test actionfilterattribute]]></category>
		<category><![CDATA[unit testing in asp net]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=19667</guid>

					<description><![CDATA[<p>Unit Test and Mock ActionFilter and ActionExecutingContext Today in this article we shall see how to Unit Test and Mock ActionFilter and mock ActionExecutingContext classes often useful for testing the controller logic in the API or ASP.NET Core MVC application. You can use the below-discussed approach using the XUnit or NUnit or MSTest framework of [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/unit-test-mock-actionfilter-asp-net-core-actionexecutingcontext-moq/">Unit Test and Mock ActionFilter in ASP.NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Unit Test and Mock ActionFilter and ActionExecutingContext</h1>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="394" src="https://www.thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-1024x394.jpg" alt="Unit Test and Mock ActionFilter " class="wp-image-19669" style="width:611px;height:235px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-1024x394.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-300x115.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-768x296.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-785x302.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter.jpg 1351w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Today in this article we shall see how to Unit Test and Mock ActionFilter and mock ActionExecutingContext classes often useful for testing the controller logic in the API or ASP.NET Core MVC application.</p>



<p></p>



<p>You can use the below-discussed approach using the XUnit or NUnit or MSTest framework of your choice.</p>



<p></p>



<p>Unit <a href="https://www.thecodebuzz.com/moq-to-mock-asynchronous-method-net-core-unit-tests/">test cases of controller-specific methods</a> make API robust and help identify any breaking changes early.</p>



<p></p>



<p>We shall use below sample code below where the controller is attributed with filter attribute i.e <strong><em>ApiInputInterceptor </em></strong>attribute as shown below example,</p>



<p></p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="736" height="166" src="https://www.thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-Controller-ASp.NET-Core-1.jpg" alt="Mock OnActionExecuting and ActionFilter" class="wp-image-19671" srcset="https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-Controller-ASp.NET-Core-1.jpg 736w, https://thecodebuzz.com/wp-content/uploads/2021/12/Unit-Test-and-Mock-Action-filter-Controller-ASp.NET-Core-1-300x68.jpg 300w" sizes="auto, (max-width: 736px) 100vw, 736px" /></figure>



<p></p>



<p>The controller with action filters includes the below-listed methods. These methods wrap the filters that run for a given action,</p>



<p></p>



<ul class="has-medium-font-size wp-block-list">
<li><code>OnActionExecuting</code> &#8211; runs before any of the action&#8217;s filters.</li>



<li><a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.controller.onactionexecuted?view=aspnetcore-6.0" target="_blank" rel="noreferrer noopener"><code>OnActionExecuted</code> </a>&#8211; runs after all of the action&#8217;s filters.</li>



<li>Or <code>OnActionExecutionAsync</code>&#8211; async format </li>
</ul>



<p></p>



<p>Below is the simplified implementation of the ApiInputInterceptor for demonstration purposes,</p>



<p></p>



<p></p>



<pre class="wp-block-code"><code>public class ApiInputInterceptor : ActionFilterAttribute,IActionFilter
    {
   
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            // do something before
            if (!context.ActionArguments.ContainsKey("Id"))
            {
                context.Result = new BadRequestObjectResult("The id must be passed as parameter");
                return;
            }
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            //throw new NotImplementedException();
        }
    }</code></pre>



<p></p>



<p>Let&#8217;s now create the Unit test case for this <em>Action filter</em> attribute which is of type ApiInputInterceptor</p>



<p></p>



<p><strong>Step 1- Create Mock of ActionContext</strong></p>



<p></p>



<p>Below is a simple way of creating a mock of ActionContext. This mock object will be needed in the next steps where we will create a mock setup for <strong><em>ActionExecutingContext</em></strong>.</p>



<p></p>



<p>Below we are creating a mock object of  HttpContext,  RouteData, and  ActionDescriptor using the <strong>moq </strong>library.</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size"> var actContext = new ActionContext(
                Mock.Of&lt;HttpContext&gt;(),
                Mock.Of&lt;RouteData&gt;(),
                Mock.Of&lt;ActionDescriptor&gt;(),
                Mock.Of&lt;ModelStateDictionary&gt;()
            );</pre>



<p></p>



<p><strong>Step 2- Create Mock of ActionExecutingContext</strong></p>



<p></p>



<p>Let&#8217;s now create the mock for <strong>ActionExecutingContext </strong>using the mock action context object as defined above. We are also passing a mock list of IFilterMetadata and Dictionary key-value pairs.</p>



<p></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">var actExecutingContext = new ActionExecutingContext(
                actionContext,
                new List&lt;IFilterMetadata&gt;(),
                new Dictionary&lt;string, object&gt;(),
                Mock.Of&lt;Controller&gt;()
            );</pre>



<p></p>



<p><strong>Step 3: Define action arguments </strong>for GET or POST method</p>



<p></p>



<p>If input arguments expect an input with the name &#8220;id&#8221; then please define it as below,</p>



<p></p>



<p><strong><em>Example </em></strong></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size"> actionExecutingContext.ActionArguments["Id"] = "123";
</pre>



<p></p>



<p>If action arguments expect a <strong><em>complex type </em></strong>as arguments especially in case POST operation then below is a sample example on defining the complex or class object as an action argument.</p>



<p></p>



<p><strong><em>Example</em></strong></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">var source = new Source
            {
                FirstName = "ABCD",
                Address = "USA",
                Id = "1232"
            };
actionExecutingContext.ActionArguments["Id"] = source;
</pre>



<p></p>



<p></p>



<p>Let&#8217;s define the action by creating the instance of <strong><em>ValidateInputAttribute </em></strong>and executing the <em><strong>OnActionExecuting </strong></em>method</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size"> //Act

  var valInputObject = new ApiInputInterceptor();
  valInputObject.OnActionExecuting(actionExecutingContext);</pre>



<p></p>



<p></p>



<p><strong>Step 4: Define Assert</strong></p>



<p></p>



<p>We are making sure the result of validation fails reports <strong><em>BadRequestObjectResult </em></strong>as shown below,</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">Assert.IsType&lt;BadRequestObjectResult&gt;(actionExecutingContext.Result);

</pre>



<p><strong>Useful References </strong></p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/restful-api-controller-unit-testing-best-practices/" target="_blank" rel="noreferrer noopener" title="RESTFul API/Controller Unit Testing – Best Practices"><strong><em>RESTFul API/Controller Unit Testing – Best Practices</em></strong></a></li>
</ul>



<p></p>



<p></p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/unit-test-mock-actionfilter-asp-net-core-actionexecutingcontext-moq/">Unit Test and Mock ActionFilter in ASP.NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/unit-test-mock-actionfilter-asp-net-core-actionexecutingcontext-moq/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Unit Test Naming Conventions Best Practices</title>
		<link>https://thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/</link>
					<comments>https://thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 15 Dec 2021 23:49:00 +0000</pubDate>
				<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[XP Practices]]></category>
		<category><![CDATA[Define naming for Test Class]]></category>
		<category><![CDATA[Define naming for Test Files]]></category>
		<category><![CDATA[integration test naming convention]]></category>
		<category><![CDATA[jest unit test naming convention]]></category>
		<category><![CDATA[manual test case naming convention]]></category>
		<category><![CDATA[name test method]]></category>
		<category><![CDATA[Naming Conventions for Test method]]></category>
		<category><![CDATA[naming test method]]></category>
		<category><![CDATA[test case naming conventions best practices]]></category>
		<category><![CDATA[unit test best practices]]></category>
		<category><![CDATA[unit test naming convention c#]]></category>
		<category><![CDATA[unit test naming convention given when then]]></category>
		<category><![CDATA[unit test naming convention python]]></category>
		<category><![CDATA[Unit Testing Naming Conventions and Standards Tests]]></category>
		<category><![CDATA[use AAA pattern unit test]]></category>
		<category><![CDATA[use given when given pattern test cases.]]></category>
		<category><![CDATA[xunit name test method]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=6698</guid>

					<description><![CDATA[<p>TDD &#8211; Unit Test Naming Conventions Best Practices I’m going to talk about simple and easy-to-understand Unit Test Naming Conventions and Best Practices that can be followed while writing Unit Testing. As we know Naming standards in any format for anything ( code, documents, unit tests, etc) are always helpful in the long run. The [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/">Unit Test Naming Conventions Best Practices</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>TDD &#8211; Unit Test Naming Conventions Best Practices</strong></h1>



<figure class="wp-block-image"><a href="https://www.thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/" target="_blank" rel="noopener"><img decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/01/Unit-Testing-Best-Practices-1.jpg?fit=785%2C349&amp;ssl=1" alt="Unit Testing Naming Conventions and Standards"/></a></figure>



<p>I’m going to talk about simple and easy-to-understand Unit Test Naming Conventions and Best Practices that can be followed while writing Unit Testing. </p>



<p></p>



<p>As we know Naming standards in any format for anything ( code, documents, unit tests, etc) are always helpful in the long run. The naming standard brings uniformity and avoids ambiguity.</p>



<p></p>



<p>Today in this article, we will cover below aspects,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-developers-confusion-on-naming">Developer&#8217;s Confusion on Naming ??</a></li><li><a href="#aioseo-naming-pattern-for-unit-testing">Naming Pattern for Unit Testing</a></li><li><a href="#aioseo-unit-test-project-naming-convention">Unit Test Project Naming Convention</a><ul><li><a href="#aioseo-app-name-unit-tests">[App-Name].Unit.Tests</a></li></ul></li><li><a href="#aioseo-unit-test-files-naming-convention">Unit Test Files Naming Convention</a><ul><li><a href="#aioseo-classnametests">[ClassName]Tests</a></li></ul></li><li><a href="#aioseo-unit-test-class-naming-convention">Unit Test Class Naming Convention</a><ul><li><a href="#aioseo-classnametests">[ClassName]Tests</a></li></ul></li><li><a href="#aioseo-unit-test-method-naming-convention">Unit Test Method Naming Convention</a><ul><li><a href="#aioseo-pattern">Pattern :</a></li><li><a href="#aioseo-unitofwork_method_behaviour">[UnitOfWork]_[Method]_[Behaviour]</a></li></ul></li><li><a href="#aioseo-unit-test-structure">Unit Test Structure</a><ul><li><a href="#aioseo-pattern">Pattern:</a><ul><li><a href="#aioseo-act---arrange---assert">Act &#8211; Arrange &#8211; Assert</a></li><li><a href="#aioseo-given-when-then">Given-When-Then</a></li></ul></li></ul></li><li><a href="#aioseo-summary">Summary</a></li></ul></div>



<p></p>



<p>Coming to Unit testing naming, however, we don&#8217;t really need to get crazy. However, by following them we get multiple benefits. </p>



<p></p>



<p>Following such naming doesn&#8217;t require any extra effort, as once put into practice, you enjoy all their benefits.</p>



<p></p>



<p>In our last article, we understood general <a href="https://www.thecodebuzz.com/unit-testing-best-practices/" target="_blank" rel="noreferrer noopener" title="Unit Test Best Practices in Software Development"><em><strong>best practices for writing the unit test cases</strong></em></a>. </p>



<p></p>



<p>However today in this article we will focus primarily on the naming conventions </p>



<p></p>



<p>Today we will see how to use the naming convention for,</p>



<p></p>



<ul class="wp-block-list">
<li>Test Method</li>
</ul>



<ul class="wp-block-list">
<li>Test Class</li>
</ul>



<ul class="wp-block-list">
<li>Test Project</li>
</ul>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-developers-confusion-on-naming">Developer&#8217;s Confusion on Naming ??</h2>



<p></p>



<p>This is a small but very common problem among developers. </p>



<p></p>



<p>There is always confusion in the Developer community on how to name and structure Unit Test cases properly. </p>



<p></p>



<p>Most often developer ends up writing their test cases without any guidelines resulting in issues like tests are not readable, not properly structured, and difficult in troubleshooting, especially on the build server where thousands of test cases run daily.</p>



<p></p>



<figure class="wp-block-image size-large"><a href="https://www.thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" width="1607" height="924" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1.jpg?fit=785%2C452&amp;ssl=1" alt="Unit Testing Naming Standards" class="wp-image-6736" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1.jpg 1607w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1-300x172.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1-1024x589.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1-768x442.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1-1536x883.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-1-785x451.jpg 785w" sizes="auto, (max-width: 1607px) 100vw, 1607px" /></a></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-naming-pattern-for-unit-testing">Naming Pattern for Unit Testing</h2>



<p></p>



<p>As we discussed in our last article on Unit testing best practices, it&#8217;s important to understand that while writing actual unit test cases everything is drilled down to finally <strong>Classes </strong>and <strong>Functions</strong>. </p>



<p></p>



<p></p>



<p>These two entities are required to be unit tested in isolation for a given functionality implemented in methods.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow.png?fit=785%2C393&amp;ssl=1" alt="Unit Testing Naming Conventions and Standards" class="wp-image-6710" width="454" height="227" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow.png 1535w, https://thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow-300x150.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow-1024x513.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow-768x385.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/UnitTest-Best-practices-flow-785x393.png 785w" sizes="auto, (max-width: 454px) 100vw, 454px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-project-naming-convention">Unit Test Project Naming Convention</h2>



<p></p>



<p>The below examples are just guidelines to help you with the naming pattern for the Test project.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>You are free to use your own customized naming pattern as required. Below are just few suggestions based on my experience. 😉</p>
</blockquote>



<p></p>



<p><strong>Pattern: </strong></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-app-name-unit-tests">[App-Name].Unit.Tests</h3>



<p></p>



<p>Example: BooksApi.Unit.Tests</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="998" height="273" src="https://www.thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-project-names.jpg" alt="Unit Testing Naming Conventions and Standards" class="wp-image-6724" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-project-names.jpg 998w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-project-names-300x82.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-project-names-768x210.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-project-names-785x215.jpg 785w" sizes="auto, (max-width: 998px) 100vw, 998px" /></figure>



<p>Other conventions like  BooksApi-Unit-Tests can also be used if found suitable.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-files-naming-convention">Unit Test Files Naming Convention </h2>



<p></p>



<p>Files can be named after the class names you are dealing with &#8230;</p>



<p></p>



<p><strong>Pattern:</strong></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-classnametests">[ClassName]Tests</h3>



<p></p>



<p><strong>Example:</strong> BookServiceTests.cs</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-file.jpg" alt="Unit test name example" class="wp-image-6725" width="449" height="530" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-file.jpg 567w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-file-254x300.jpg 254w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-file-441x520.jpg 441w" sizes="auto, (max-width: 449px) 100vw, 449px" /></figure>



<p></p>



<p><strong>Tips:</strong></p>



<ul class="wp-block-list">
<li>Every class with the public method (at least one method) should have a test file created. (This also means you should refactor your files as per classes)</li>
</ul>



<ul class="wp-block-list">
<li>Make sure to write unit test cases for all public APIs for each given class.</li>
</ul>



<ul class="wp-block-list">
<li>Each test file should be completely isolated from other files.</li>
</ul>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-class-naming-convention">Unit Test Class Naming Convention </h2>



<p></p>



<p>You need a test class to encapsulate all your test cases. This test class provides an entry point to test cases depending on the configuration. </p>



<p>This also helps to initialize the test data required for test cases.</p>



<p></p>



<p><strong>Pattern:</strong></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-classnametests">[ClassName]Tests</h3>



<p></p>



<p>Example:  &#8216;EmployeesTests&#8217; where Employee is a class name.</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="2113" height="912" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names.jpg?fit=785%2C339&amp;ssl=1" alt="" class="wp-image-6727" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names.jpg 2113w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-300x129.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-1024x442.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-768x331.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-1536x663.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-2048x884.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-file-names-785x339.jpg 785w" sizes="auto, (max-width: 2113px) 100vw, 2113px" /></figure>



<p></p>



<p><strong>Tips:</strong></p>



<p></p>



<ul class="wp-block-list">
<li>Name your Test Class as per the business class name. </li>



<li>Each Test Class should be defined in a separate test file as discussed above.</li>



<li>Each Test Class should have a mechanism to initialize mock or test data</li>



<li>Each test class should be public.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-method-naming-convention">Unit Test Method Naming Convention</h2>



<p></p>



<p>Each Unit test method should be unit tested in isolation. This isolation can be simplified by a Class and all its methods.</p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-pattern">Pattern :</h3>



<p></p>



<h3 class="wp-block-heading" id="aioseo-unitofwork_method_behaviour">[UnitOfWork]_[Method]_[Behaviour]</h3>



<p></p>



<p>Example: BookService_GetBookAsync_InValidBookID_Failure</p>



<p></p>



<figure class="wp-block-image size-large"><a href="https://www.thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" width="1142" height="531" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1.jpg?fit=785%2C365&amp;ssl=1" alt="Unit Test Naming Conventions Best Practices" class="wp-image-6730" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1.jpg 1142w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1-300x139.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1-1024x476.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1-768x357.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-name-1-785x365.jpg 785w" sizes="auto, (max-width: 1142px) 100vw, 1142px" /></a></figure>



<h2 class="wp-block-heading" id="aioseo-unit-test-structure">Unit Test Structure </h2>



<p></p>



<p>One can follow the AAA or  Given-When-Then style pattern while structuring your test cases.</p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-pattern">Pattern:</h3>



<p></p>



<h4 class="wp-block-heading" id="aioseo-act---arrange---assert">Act &#8211; Arrange &#8211; Assert</h4>



<p></p>



<p>The essential idea of the <strong>AAA </strong>pattern is to break down writing your test into three sections.</p>



<p></p>



<ul class="wp-block-list">
<li><strong>Arrange</strong>: This describes a preconditioned state of the test before you begin to test the behavior you&#8217;re specifying in this scenario.  Helps you create required test preparations, test data, mocking, etc.</li>
</ul>



<ul class="wp-block-list">
<li><strong>Act</strong>&#8211; This section tests the behavior that you&#8217;re specifying. </li>
</ul>



<ul class="wp-block-list">
<li><strong>Assert</strong>&#8211; This section describes the changes you expect due to the defined inputs through arranging and specified behavior through Act. </li>
</ul>



<p></p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.thecodebuzz.com/integration-testing-best-practices-agile/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure.jpg?fit=785%2C643&amp;ssl=1" alt="Unit Test Naming Conventions Best Practices" class="wp-image-6733" width="569" height="466" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure.jpg 1128w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure-300x246.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure-1024x839.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure-768x629.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/unit-testing-naming-conventions-for-test-method-structure-635x520.jpg 635w" sizes="auto, (max-width: 569px) 100vw, 569px" /></a></figure>



<p></p>



<p>Some of you might like one more pattern as below,</p>



<p></p>



<p><strong>Pattern</strong>:</p>



<p></p>



<h4 class="wp-block-heading" id="aioseo-given-when-then">Given-When-Then&nbsp; </h4>



<p></p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.thecodebuzz.com/integration-testing-best-practices-agile/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/11/image-15.png?fit=785%2C654&amp;ssl=1" alt="Unit Test Naming Conventions Best Practices" class="wp-image-6740" width="561" height="468" srcset="https://thecodebuzz.com/wp-content/uploads/2019/11/image-15.png 1109w, https://thecodebuzz.com/wp-content/uploads/2019/11/image-15-300x250.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/11/image-15-1024x853.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/11/image-15-768x640.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/11/image-15-624x520.png 624w" sizes="auto, (max-width: 561px) 100vw, 561px" /></a></figure>



<p></p>



<p>The above pattern has the same meaning on the structure as defined above for the <strong>AAA </strong>pattern. </p>



<p><strong><em>Given-When-Then</em></strong> is most popular in Behavior-Driven Development&nbsp;(<em><strong>BDD</strong></em>) and Functional Testing.</p>



<p></p>



<p>Do you find the above conventions helpful?</p>



<p></p>



<p><strong><em>References: </em></strong></p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/integration-testing-best-practices-agile/" title="Integration Testing Best Practices in Agile" target="_blank" rel="noreferrer noopener"><strong><em>Integration Testing Best Practices in Agile</em></strong></a></li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/unit-testing-best-practices/" target="_blank" rel="noreferrer noopener" title="Unit Test Best Practices in Software Development"><strong><em>Top 10 Unit Test Best Practices in Software Development</em></strong></a></li>
</ul>



<p></p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-summary">Summary</h2>



<p></p>



<p>In this post, we learned a few basic and easy-to-use naming conventions for Unit Testing. We looked at the different naming convention which is useful for Test Project, Test Files, Test Class, Test method and Test method structure, etc.</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/">Unit Test Naming Conventions Best Practices</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/tdd-unit-testing-naming-conventions-and-standards/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Unit Test and Mock IOptions in .NET Core</title>
		<link>https://thecodebuzz.com/unit-test-mock-ioption-net-core-ioption-moq-appsettings/</link>
					<comments>https://thecodebuzz.com/unit-test-mock-ioption-net-core-ioption-moq-appsettings/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 25 Oct 2021 18:30:00 +0000</pubDate>
				<category><![CDATA[XP Practices]]></category>
		<category><![CDATA[accessing configuration in net core test projects]]></category>
		<category><![CDATA[how to mock appsettings json in net core]]></category>
		<category><![CDATA[ioptionsmonitor unit test]]></category>
		<category><![CDATA[Mock IOptions .net core]]></category>
		<category><![CDATA[mock<iconfiguration]]></category>
		<category><![CDATA[mock<iconfiguration getsection]]></category>
		<category><![CDATA[mock<ioptionsmonitor]]></category>
		<category><![CDATA[nsubstitute ioptions]]></category>
		<category><![CDATA[options.create example]]></category>
		<category><![CDATA[Unit Test and Mock IOptions]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=18843</guid>

					<description><![CDATA[<p>Unit Test and Mock IOptions &#60;T&#62; .NET Core Today in this article, we shall see how to Unit Test and Mock IOptions &#60;T&#62; instance often used in Controller or other modules for injecting the configuration details. Today in this article, we will cover below aspects, The IOptions interface pattern provides access to configuration details in [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/unit-test-mock-ioption-net-core-ioption-moq-appsettings/">Unit Test and Mock IOptions in .NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Unit Test and Mock IOptions &lt;T&gt; .NET Core</h1>



<p>Today in this article, we shall see how to Unit Test and Mock IOptions &lt;T&gt; instance often used in Controller or other modules for injecting the configuration details.</p>



<p>Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-unit-test-ioption-without-mock">Unit test IOption without Mock</a></li><li><a href="#aioseo-unit-test-ioption-by-mock-ioption">Unit Test IOption by Mock IOption</a></li></ul></div>



<p>The IOptions interface pattern provides access to configuration details in related classes as well as<br>the option to load config data depending on the situation.</p>



<p></p>



<p>The&nbsp;<strong>IOptions&nbsp;</strong>interface&nbsp;will&nbsp;be&nbsp;used&nbsp;to&nbsp;load&nbsp;the&nbsp;configuration&nbsp;as&nbsp;needed&nbsp;in&nbsp;the&nbsp;program.</p>



<p></p>



<p><strong>Example:</strong></p>



<pre class="wp-block-preformatted has-medium-font-size">public class ProducerController : ControllerBase
     {
         readonly ProducerConfigSettings _producerConfigSetting;
         public ProducerController(IOptions producerConfig)
         {
             _producerConfigSetting = producerConfig.Value;
         }

.

.
     }</pre>



<p>The above<strong> </strong>shows <strong>ProducerController </strong>which is a controller class injecting Apsettings.json key-value pair using the IOp<strong>t</strong>ion pattern.</p>



<p></p>



<p>For more details on <strong>IOption </strong>Pattern, please visit the below article,</p>



<p></p>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/configuration-in-net-core-2-1/" target="_blank" rel="noreferrer noopener" title="Configuration in ASP.NET Core"><strong><em>Configuration in ASP.NET Core</em></strong></a></li></ul>



<p></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-ioption-without-mock">Unit test IOption without Mock</h2>



<p></p>



<p>In this approach, you certainly need not have to mock the <strong><em>Apsettings </em></strong>object. You can send test settings details via the settings object as below and test all positive and negative scenarios as required.</p>



<p></p>



<p><strong>Example</strong></p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
            //Arrange
            ProducerConfigSettings appSettings = new ProducerConfigSettings() 
            { 
                Key1 = &quot;testkey1&quot;,
                Key2 = &quot;Testkey2&quot; 
            };
            IOptions&lt;ProducerConfigSettings&gt; options = Options.Create(appSettings);
            ProducerController controller = new ProducerController(options);


</pre></div>


<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-1024x495.jpg" alt="Unit Test and Mock IOptions" class="wp-image-18852" width="783" height="378" srcset="https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-1024x495.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-300x145.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-768x372.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-1536x743.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings-785x380.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptions-apsettings.jpg 1792w" sizes="auto, (max-width: 783px) 100vw, 783px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-unit-test-ioption-by-mock-ioption">Unit Test IOption by Mock IOption</h2>



<p></p>



<p>In this approach, you can mock the Apsettings object. You can send mocked settings details via the settings object as below and test all positive and negative scenarios as required.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; highlight: [7]; title: ; notranslate">
           //Arrange
            ProducerConfigSettings appSettings = new ProducerConfigSettings()
            {
                Key1 = &quot;testkey1&quot;,
                Key2 = &quot;Testkey2&quot;
            };
            var mockIOption = new Mock&lt;IOptions&lt;ProducerConfigSettings&gt;&gt;();
            // We need to set the Value of IOptions to be the SampleOptions Class
            mockIOption.Setup(ap =&gt; ap.Value).Returns(appSettings);
            ProducerController controller = new ProducerController(mockIOption.Object);


</pre></div>


<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="534" src="https://www.thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-1024x534.jpg" alt="Mock IOptions .net core, unit test IOptions " class="wp-image-18853" srcset="https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-1024x534.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-300x157.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-768x401.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-1536x801.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing-785x410.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/10/how-to-initialize-ioptionappsettings-for-unit-testing.jpg 1844w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p><strong>Finally</strong>, Using any of the above approaches when you run the test cases, it starts using test/mocked app settings, instead of pulling it from the actual <em><strong>apsettings.jso</strong></em>n file.</p>



<p></p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="307" src="https://www.thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-1024x307.jpg" alt="Unit Test IOptions" class="wp-image-18850" srcset="https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-1024x307.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-300x90.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-768x230.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-1536x461.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-2048x614.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2021/10/net-core-unit-testing-mock-ioptionst-785x235.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p><strong><em>References</em></strong>: </p>



<p></p>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/restful-api-controller-unit-testing-best-practices/" target="_blank" rel="noreferrer noopener" title="RESTFul API/Controller Unit Testing – Best Practices"><strong><em></em></strong></a><strong><em><a href="https://www.thecodebuzz.com/configuration-in-net-core-2-1/" target="_blank" rel="noreferrer noopener"><strong><em>Configuration in ASP.NET Core</em></strong></a></em></strong></li></ul>



<p></p>



<p>That&#8217;s all! Happy coding!</p>



<p></p>



<p>Does this help you fix your issue? </p>



<p></p>



<p>Do you have any better solutions or suggestions? Please sound off your comments below.</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/unit-test-mock-ioption-net-core-ioption-moq-appsettings/">Unit Test and Mock IOptions in .NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/unit-test-mock-ioption-net-core-ioption-moq-appsettings/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Git Branching Best Practices &#8211; Trunk-Based Development</title>
		<link>https://thecodebuzz.com/trunk-based-development-best-practices/</link>
					<comments>https://thecodebuzz.com/trunk-based-development-best-practices/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 02 Sep 2021 02:43:00 +0000</pubDate>
				<category><![CDATA[CICD]]></category>
		<category><![CDATA[XP Practices]]></category>
		<category><![CDATA[Benefits of Trunk Based Development]]></category>
		<category><![CDATA[GitFlow Vs Trunk Development]]></category>
		<category><![CDATA[Trunk Based Development]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=5173</guid>

					<description><![CDATA[<p>Git Branching Best Practices &#8211; Trunk-Based Development Trunk-based development is a prominent source code Branching Strategy that follows a set of defined principles and best practices to perform code development on a branch called &#8216;Trunk&#8217; or &#8216;Master&#8217; in a collaborative way. A source-control branching model, where developers collaborate on code in a single branch called [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/trunk-based-development-best-practices/">Git Branching Best Practices – Trunk-Based Development</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Git Branching Best Practices &#8211; Trunk-Based Development </strong></h1>


<div class="wp-block-image">
<figure class="aligncenter is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices.jpg?fit=785%2C608&amp;ssl=1" alt="Git Branching Best Practices - Trunk-Based Development " class="wp-image-5281" width="408" height="316" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices.jpg 1109w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices-300x232.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices-1024x793.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices-768x595.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-best-practices-671x520.jpg 671w" sizes="auto, (max-width: 408px) 100vw, 408px" /></figure>
</div>


<p>Trunk-based development is a prominent source code Branching Strategy that follows a set of defined principles and best practices to perform code development on a branch called &#8216;Trunk&#8217; or &#8216;Master&#8217; in a collaborative way. </p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><em>A source-control branching model, where developers collaborate on code in a single branch called ‘trunk’ *, resist any pressure to create other long-lived development branches by employing documented techniques. They therefore avoid merge hell, do not break the build, and live happily ever after. </em></p>



<p></p>



<p>_ Source <a href="https://trunkbaseddevelopment.com/" target="_blank" rel="noreferrer noopener">https://trunkbaseddevelopment.com/</a></p>
</blockquote>



<p></p>



<p>We will cover the below aspects in the article,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-origin-and-merge-hell">Origin and Merge Hell</a></li><li><a href="#aioseo-is-it-feasible-to-follow-the-trunk-master-approach">Is it feasible to follow the Trunk/Master Approach?</a></li><li><a href="#aioseo-feature-toggle---inevitable">Feature Toggle &#8211; Inevitable</a></li><li><a href="#aioseo-benefits-of-trunk-based-development">Benefits of Trunk-Based Development</a></li><li><a href="#aioseo-best-practices-of-trunk-based-development">Best Practices of Trunk-Based Development</a><ul><li><a href="#aioseo-develop-on-the-trunk-master">Develop the Trunk/Master</a></li><li><a href="#aioseo-feature-branch-life-span-a-few-days1-3-days">Feature Branch life span a few days(1-3 days)</a></li><li><a href="#aioseo-create-feature-branches-from-master-trunk">Create Feature branches from the Master/Trunk</a></li><li><a href="#aioseo-feature-branches-can-be-aligned-with-the-small-feature-and-hence-user-stories-or-task">Feature Branches can be Aligned with the small feature and hence user stories or task</a></li><li><a href="#aioseo-clean-merges-to-trunk-master">Clean merges to Trunk/Master</a></li><li><a href="#aioseo-dont-commit-to-master-trunk-directly">Don&#8217;t commit to Master/Trunk directly</a></li><li><a href="#aioseo-merge-should-be-from-a-feature-branch-to-master-trunk">Merge should be from a Feature branch to the Master/Trunk</a></li><li><a href="#aioseo-every-merge-should-be-production-ready">Every merge should be production-ready</a></li><li><a href="#aioseo-merges-to-trunk-master">Merges to Trunk/Master</a></li><li><a href="#aioseo-keep-trunk-master-green">Keep Trunk/Master Green</a></li><li><a href="#aioseo-release-branch-to-master-branch-merge-should-be-avoided">Release branch to Master branch merge should be avoided</a></li><li><a href="#aioseo-summary">Summary</a></li></ul></li></ul></div>



<p></p>



<p><strong><em>Trunk-based development</em></strong> is getting huge traction recently. </p>



<p></p>



<p>These recognitions are mainly due to the realization of the fact after a decade of experience and learning on the various issue of traditional <strong>VCS </strong>(Version Control system)  like Merge hell, Testing failure followed by a delay in delivering a feature and then delay in testing and acceptance, etc.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-origin-and-merge-hell">Origin and Merge Hell</h2>



<p></p>



<p class="has-text-align-left">The code integration phase is still an important phase even in modern code development methodologies. Generally, once a feature development is over as we know of integration of the code from different developers. </p>



<p></p>



<p class="has-text-align-left">This merging sometimes also depends on multiple aspects like environment, the feature is integrated, the client-specific requirement being addressed, etc.</p>



<p></p>



<p class="has-text-align-left">This merging is always challenging, as it involves a huge code base merge developed over a period of time.</p>



<p></p>



<p>The integration phase is always critical to delivery. </p>



<p></p>



<p>If any issue arising at that time could affect directly the delivery of the product.</p>



<p></p>



<p>The issue could become worse with an approach of having multiple parallel repositories in a different environment dealing with code movement from one environment to another environment. </p>



<p></p>



<p></p>



<p>Finally, These problems are always man-made. The good thing is these problems are solvable with best practices.</p>



<p> </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1285" height="924" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others.jpg?fit=785%2C564&amp;ssl=1" alt="Trunk Based Development " class="wp-image-6748" srcset="https://thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others.jpg 1285w, https://thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others-300x216.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others-1024x736.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others-768x552.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/12/Trunk-Based-Development-Vs-Git-Flow-Vs-Others-723x520.jpg 723w" sizes="auto, (max-width: 1285px) 100vw, 1285px" /></figure>



<p></p>



<p>There are many mechanisms for practicing lean-agile methodologies. </p>



<p></p>



<p>Trunk-based development is slowly becoming one of the methods helping with a few common issues on code merge thereby targeting speed to the market initiative.</p>



<p> </p>



<p>TBD actually complements your already established lean-agile practices and the team can get value from its usage. </p>



<p></p>



<p>Trunk Based development-based branching strategies help in practicing frequent releases and delivery of features and helping to achieve speed to the market initiative.</p>



<p></p>



<p>Trunk Based Development&#8217;s main advantage is that it keeps feature/code near to the production readiness right from the kickstart of a project.</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices.jpg?fit=785%2C515&amp;ssl=1" alt="feature/code Trunk Based Development" class="wp-image-5278" width="482" height="316" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices.jpg 1408w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices-300x197.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices-1024x672.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices-768x504.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Practices-785x515.jpg 785w" sizes="auto, (max-width: 482px) 100vw, 482px" /></figure>



<p></p>



<p>It&#8217;s important to understand that when a feature or code is near to the release Or production readiness continuously, the team gets a lot of flexibility on revisiting the features, introducing a change in a feature or updating an implementation, or making changes to code as per the requirements.</p>



<p></p>



<p>Also, the team can revisit on design and architecture of applications if needed. </p>



<p></p>



<p>The team keeps on integrating code even if the feature is not complete. The idea here is simple, issues are easy to fix when they are small. </p>



<p></p>



<p>Trunk-based development encourages small features to be integrated in an incremental way.</p>



<p></p>



<p>A known limitation in the world of waterfall dealing with legacy source code, you will typically observe one continuous build that culminates in one deployment for a bunch of features spanning over a period of time.</p>



<p></p>



<p>Which most time produces multiple issues like merge hell and bugs etc.</p>



<p> </p>



<h2 class="wp-block-heading" id="aioseo-is-it-feasible-to-follow-the-trunk-master-approach">Is it feasible to follow the Trunk/Master Approach?</h2>



<p></p>



<p>The feasibility of following the trunk-based development could be a question for most of us.</p>



<p></p>



<p>The simple answer is &#8216;absolutely&#8217; it is feasible. </p>



<p></p>



<p>There are multiple benefits of using the Trunk approach as explained in the &#8220;Benefits&#8221; section below.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-feature-toggle---inevitable">Feature Toggle &#8211; Inevitable</h2>



<p> </p>



<p>There are multiple supportive techniques useful for following Trunk based development. </p>



<p></p>



<p>The use of Feature toggles is <em>inevitable</em>. </p>



<p></p>



<p>Feature toggles are dependable companions of trunk development and help to achieve the Trunk approach properly.</p>



<p></p>



<p>Trunk-based development can regulate the software development process within your sprint or iteration cycle. &nbsp;</p>



<p></p>



<p>Teams develop a cadence for a release-ready feature implementation which is integrated together with feature flags.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-benefits-of-trunk-based-development">Benefits of Trunk-Based Development </h2>



<p></p>



<ul class="wp-block-list">
<li>Small incremental Feature development gives greater visibility of features being developed.</li>
</ul>



<ul class="wp-block-list">
<li><strong>Compliment the CI-CD</strong> process with Continuous Integration and continuous deployment of code.  </li>
</ul>



<ul class="wp-block-list">
<li>Small Feature development can be aligned with lean Agile methodologies improving the velocity of the team overall.</li>
</ul>



<ul class="wp-block-list">
<li>Code on Master/Trunk is always ready to be released due to only one Trunk.</li>
</ul>



<ul class="wp-block-list">
<li>Reduces the cost of manual code merge (usually done in the form of the integration process of the codebase).</li>
</ul>



<ul class="wp-block-list">
<li>It enables the team&#8217;s ability to release new features more frequently. </li>
</ul>



<ul class="wp-block-list">
<li>Trunk methodologies with a combination of practices improve the quality of deliverables.</li>
</ul>



<ul class="wp-block-list">
<li>Shift-left enablement. </li>
</ul>



<ul class="wp-block-list">
<li>Cross-team collaboration with <strong>XP </strong>practices.</li>
</ul>



<ul class="wp-block-list">
<li>Eliminates heavy code merges. </li>
</ul>



<p></p>



<p></p>



<h1 class="wp-block-heading" id="aioseo-best-practices-of-trunk-based-development"><strong>Best Practices of Trunk-Based Development</strong></h1>



<p></p>



<h2 class="wp-block-heading" id="aioseo-develop-on-the-trunk-master">Develop the Trunk/Master</h2>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1.jpg?fit=785%2C515&amp;ssl=1" alt="Git Branching Best Practices" class="wp-image-5269" width="511" height="335" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1.jpg 1408w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1-300x197.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1-1024x672.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1-768x504.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-1-785x515.jpg 785w" sizes="auto, (max-width: 511px) 100vw, 511px" /></figure>



<ul class="wp-block-list">
<li>That means one and only Master or Trunk should be used for all development.</li>



<li>This is different from Git Flow where actual development happens on dedicated branch-like <strong>DEV</strong> then Test etc.</li>



<li>One should always use Feature Branches for small feature development.</li>



<li>Small Feature Branch should not last for more than 1-2-3 days.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-feature-branch-life-span-a-few-days1-3-days">Feature Branch life span a few days(1-3 days)</h2>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices.jpg?fit=785%2C517&amp;ssl=1" alt="Feature Branch life span a few days" class="wp-image-5260" width="492" height="323" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices.jpg 1403w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices-300x198.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices-1024x674.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices-768x506.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-contineous-merge-on-master-Best-Pracitices-785x517.jpg 785w" sizes="auto, (max-width: 492px) 100vw, 492px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>Developers should develop a practice of not keeping the code to themselves.</li>



<li>The code should be merged with Master within a few days, typically 1-3 days.</li>



<li>Code merge should be done for what you own that day with the precondition of a successful build, and test cases passing.</li>



<li>Code merge can be done even if the feature is not complete. Make sure build and test cases are passing. </li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-create-feature-branches-from-master-trunk">Create Feature branches from the Master/Trunk</h2>



<p></p>



<p>Example</p>



<p></p>


<div class="wp-block-image">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="301" height="212" src="https://www.thecodebuzz.com/wp-content/uploads/2019/08/image-3.png" alt="Create Feature branches from Master/Trunk" class="wp-image-5261"/></figure>
</div>


<p></p>



<ul class="wp-block-list">
<li>Ex, If using<strong> Git</strong> as<strong> VCS </strong>then origin/master (remote) should be used for creating a Feature branch.</li>



<li>The idea here is every new development should progress using the latest available code from Master/Trunk.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-feature-branches-can-be-aligned-with-the-small-feature-and-hence-user-stories-or-task">Feature Branches can be Aligned with the small feature and hence user stories or task </h2>



<p></p>



<ul class="wp-block-list">
<li>New Feature branches can be created for small development and can be aligned with user stories or tasks.</li>



<li>If aligned with a user story or task, please make sure the Feature branch code doesn&#8217;t last long beyond 2-3 days.</li>



<li>The idea here is to merge and deploy small features in logical chunks and as early as possible usually within 1-3 days.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-clean-merges-to-trunk-master">Clean merges to Trunk/Master</h2>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2.jpg?fit=785%2C454&amp;ssl=1" alt="Clean merges to Trunk/Master" class="wp-image-5275" width="488" height="281" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2.jpg 1597w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2-300x174.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2-1024x592.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2-768x444.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2-1536x889.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-feature-branch-Best-Pracitices-sync-review-2-785x454.jpg 785w" sizes="auto, (max-width: 488px) 100vw, 488px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>The small feature developed should be validated, and reviewed within the Feature branch itself right before the merging to Master/Trunk.</li>



<li>Always sync your changes from the source control. </li>



<li>Feature branch code should be reviewed before the merge to the Master/Trunk.</li>



<li>Clean merges here means code that is in a Green state i.e passes build, unit test, etc.</li>



<li>Do only clean merges to Trunk which are validated and reviewed</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-dont-commit-to-master-trunk-directly">Don&#8217;t commit to Master/Trunk directly</h2>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/image-5.jpg?fit=785%2C305&amp;ssl=1" alt="Don't commit to Master/Trunk directly" class="wp-image-5268" width="526" height="204" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/image-5.jpg 2378w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-300x117.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-1024x398.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-768x298.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-1536x597.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-2048x796.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/08/image-5-785x305.jpg 785w" sizes="auto, (max-width: 526px) 100vw, 526px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>It&#8217;s recommended not to commit directly to the Master/Trunk branch instead one should create a Feature branch (short 1-3 days).</li>
</ul>



<ul class="wp-block-list">
<li>It&#8217;s recommended to create a feature branch for every merge.</li>
</ul>



<ul class="wp-block-list">
<li>Smaller teams sometimes tend to check directly to the Master which is okay for a team of 1 or 2 (if code review is followed strictly.)</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-merge-should-be-from-a-feature-branch-to-master-trunk">Merge should be from a Feature branch to the Master/Trunk</h2>



<p></p>



<ul class="wp-block-list">
<li>Merge should be unidirectional that is from a Feature branch to Master/Trunk. </li>
</ul>



<ul class="wp-block-list">
<li>Merge from the Release branch to the Master branch can be avoided. </li>
</ul>



<ul class="wp-block-list">
<li>Intermediate merges to master (Trunk) are not allowed. </li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-every-merge-should-be-production-ready">Every merge should be production-ready</h2>



<p></p>



<ul class="wp-block-list">
<li>Do a clean merge with known and agreed functionalities including limitations if any.</li>



<li>Do clean merges even if the feature is not completed fully.</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-merges-to-trunk-master">Merges to Trunk/Master</h2>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch.jpg?fit=785%2C555&amp;ssl=1" alt="Merges to Trunk/Master" class="wp-image-5273" width="519" height="367" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch.jpg 1306w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch-300x212.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch-1024x724.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch-768x543.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-with-short-lived-branch-735x520.jpg 735w" sizes="auto, (max-width: 519px) 100vw, 519px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>Merges between one Feature branch to another Feature branch must be avoided.</li>
</ul>



<ul class="wp-block-list">
<li>The best practice is to follow the uni-directional merge that is merge of Feature Branch to Master/Trunk should be used.</li>
</ul>



<p>          <strong>Feature branch&gt;&gt;&gt;&gt; Master/Trunk&gt;&gt;&gt;&gt;&gt;&gt;Release Branch</strong></p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-keep-trunk-master-green">Keep Trunk/Master Green</h2>



<p></p>



<p>The definition of green can be defined as below,</p>



<p></p>



<ul class="wp-block-list">
<li>Green for the compile and build.</li>
</ul>



<ul class="wp-block-list">
<li>Green for the Feature being developed. It should work with known and agreed functionality.</li>
</ul>



<ul class="wp-block-list">
<li>Green for the acceptable Test including unit tests or integration test cases.</li>
</ul>



<ul class="wp-block-list">
<li>If the build fails, revert your changes back to the previous best state of code. One should create a new Feature branch for fixing build issues. </li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-release-branch-to-master-branch-merge-should-be-avoided">Release branch to Master branch merge should be avoided</h2>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master.jpg?fit=785%2C366&amp;ssl=1" alt="Avoid Release branch to Master branch merge" class="wp-image-5274" width="454" height="211" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master.jpg 1228w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master-300x140.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master-1024x478.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master-768x358.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Trunk-Based-Development-release-to-master-785x366.jpg 785w" sizes="auto, (max-width: 454px) 100vw, 454px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>Merge from the release Branch to the master should be avoided. There are rare exceptions though (which I will talk about in future articles).</li>
</ul>



<p></p>



<p><strong><em>References</em></strong></p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/cherry-pick-in-github-step-by-step/" target="_blank" rel="noreferrer noopener" title="Cherry Pick in GitHub"><strong><em>Cherry Pick in Gi for Trunk-based Development</em></strong></a></li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-summary">Summary</h2>



<p></p>



<p>Trunk-based development is a prominent source code <strong>Branching Strategy </strong>that follows a set of defined principles and best practices to perform code development on a single branch called &#8216;<strong><em>Trunk&#8217; or &#8216;Master&#8217; </em></strong>in a collaborative way thereby minimizing the merge/integration pain. </p>



<p></p>



<p>It complements continuous integration and continuous delivery by keeping the code &#8220;ready to release&#8221; state and developing a cadence of merging small changes in an incremental way.</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p><p>The post <a href="https://thecodebuzz.com/trunk-based-development-best-practices/">Git Branching Best Practices – Trunk-Based Development</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/trunk-based-development-best-practices/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
