<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Unit - Tag - My Notes</title><link>https://blog.emecas.net/tags/unit/</link><description>Unit - Tag - My Notes</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 29 Apr 2020 18:54:24 -0400</lastBuildDate><atom:link href="https://blog.emecas.net/tags/unit/" rel="self" type="application/rss+xml"/><item><title>7 Popular Unit Test Naming Conventions</title><link>https://blog.emecas.net/posts/2020-04-29-7-popular-unit-test-naming-conventions/</link><pubDate>Wed, 29 Apr 2020 18:54:24 -0400</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2020-04-29-7-popular-unit-test-naming-conventions/</guid><description><![CDATA[<p>7 Popular Unit Test Naming Conventions<br>
<a href="https://dzone.com/articles/7-popular-unit-test-naming" target="_blank" rel="noopener noreffer ">https://dzone.com/articles/7-popular-unit-test-naming</a></p>
<p>1. MethodName_StateUnderTest_ExpectedBehavior: There are arguments against this strategy that if method names change as part of code refactoring 	than test name like this should also change or it becomes difficult to comprehend at a later stage. Following are some of the example:<br>
isAdult_AgeLessThan18_False<br>
withdrawMoney_InvalidAccount_ExceptionThrown<br>
admitStudent_MissingMandatoryFields_FailToAdmit<br>
2. MethodName_ExpectedBehavior_StateUnderTest: Slightly tweeked from above, but a section of developers also recommend using this naming technique. This technique also has disadvantage that if method names get changed, it becomes difficult to comprehend at a later stage. Following is how tests in first example would read like if named using this technique:<br>
isAdult_False_AgeLessThan18<br>
withdrawMoney_ThrowsException_IfAccountIsInvalid<br>
admitStudent_FailToAdmit_IfMandatoryFieldsAreMissing<br>
3. test[Feature being tested]: This one makes it easy to read the test as the feature to be tested is written as part of test name. Although, there are arguments that the “test” prefix is redundant. However, some sections of developer love to use this technique. Following is how the above tests would read like if named using this technique:<br>
testIsNotAnAdultIfAgeLessThan18<br>
testFailToWithdrawMoneyIfAccountIsInvalid<br>
testStudentIsNotAdmittedIfMandatoryFieldsAreMissing<br>
4. Feature to be tested: Many suggests that it is better to simply write the feature to be tested because one is anyway using annotations to identify method as test methods. It is also recommended for the reason that it makes unit tests as alternate form of documentation and avoid code smells. Following is how tests in first example would read like if named using this technique:<br>
IsNotAnAdultIfAgeLessThan18<br>
FailToWithdrawMoneyIfAccountIsInvalid<br>
StudentIsNotAdmittedIfMandatoryFieldsAreMissing<br>
5. Should_ExpectedBehavior_When_StateUnderTest: This technique is also used by many as it makes it easy to read the tests. Following is how tests in first example would read like if named using this technique:<br>
Should_ThrowException_When_AgeLessThan18<br>
Should_FailToWithdrawMoney_ForInvalidAccount<br>
Should_FailToAdmit_IfMandatoryFieldsAreMissing<br>
6. When_StateUnderTest_Expect_ExpectedBehavior: Following is how tests in first example would read like if named using this technique:<br>
When_AgeLessThan18_Expect_isAdultAsFalse<br>
When_InvalidAccount_Expect_WithdrawMoneyToFail<br>
When_MandatoryFieldsAreMissing_Expect_StudentAdmissionToFail<br>
7. Given_Preconditions_When_StateUnderTest_Then_ExpectedBehavior: This approach is based on naming convention developed as part of Behavior-Driven Development (BDD). The idea is to break down the tests into three part such that one could come up with preconditions, state under test and expected behavior to be written in above format. Following is how tests in first example would read like if named using this technique:<br>
Given_UserIsAuthenticated_When_InvalidAccountNumberIsUsedToWithdrawMoney_Then_TransactionsWillFail</p>]]></description></item><item><title>kbilsted/StatePrinter</title><link>https://blog.emecas.net/posts/2019-05-29-kbilsted-stateprinter/</link><pubDate>Wed, 29 May 2019 17:06:23 +0000</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2019-05-29-kbilsted-stateprinter/</guid><description><![CDATA[<p>kbilsted/StatePrinter<br>
Automating unit testing and ToString() coding<br>
C# repository by kbilsted, created in 2014, with 94 stars and 31 forks. License: Apache-2.0. Starred on 2019-05-29.<br>
<a href="https://github.com/kbilsted/StatePrinter" target="_blank" rel="noopener noreffer ">https://github.com/kbilsted/StatePrinter</a></p>
<hr>
<p><em>Source: starred on GitHub on 2019-05-29: <a href="https://github.com/kbilsted/StatePrinter" target="_blank" rel="noopener noreffer ">kbilsted/StatePrinter</a>.</em></p>]]></description></item><item><title>Creating Mock Objects for C# Unit Tests, using Moq</title><link>https://blog.emecas.net/posts/2019-02-23-creating-mock-objects-for-c-unit-tests-using-moq/</link><pubDate>Sat, 23 Feb 2019 12:28:29 -0500</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2019-02-23-creating-mock-objects-for-c-unit-tests-using-moq/</guid><description><![CDATA[<p>Creating Mock Objects for C# Unit Tests, using Moq<br>
<a href="https://scottlilly.com/creating-mock-objects-for-c-unit-tests-using-moq/" target="_blank" rel="noopener noreffer ">https://scottlilly.com/creating-mock-objects-for-c-unit-tests-using-moq/</a><br>
In my demonstration of the Dependency Injection design pattern, I manually created a mock object. This let me perform unit tests without needing to access a database.<br>
Here is how you can use the Moq library, to eliminate writing the code for manual mock classes.<br>
If you aren’t familiar with dependency injection, please read this article first</p>
<hr>
<p><em>Source: commit <a href="https://github.com/emecas/My-Notes/commit/d0b85b772384455b2bc1f660181a59fa56e782f9" target="_blank" rel="noopener noreffer "><code>d0b85b7</code></a> in My-Notes.</em></p>]]></description></item><item><title>ArchUnit - checking the architecture of your Java code</title><link>https://blog.emecas.net/posts/2019-02-19-archunit-checking-the-architecture-of-your-java-code/</link><pubDate>Tue, 19 Feb 2019 13:37:59 -0500</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2019-02-19-archunit-checking-the-architecture-of-your-java-code/</guid><description><![CDATA[<p>ArchUnit<br>
<a href="https://www.archunit.org/" target="_blank" rel="noopener noreffer ">https://www.archunit.org/</a><br>
ArchUnit is a free, simple and extensible library for checking the architecture of your Java code using any plain Java unit test framework. That is, ArchUnit can check dependencies between packages and classes, layers and slices, check for cyclic dependencies and more. It does so by analyzing given Java bytecode, importing all classes into a Java code structure. You can find examples for the current release at ArchUnit Examples and the sources on GitHub.<br>
<a href="https://github.com/TNG/ArchUnit" target="_blank" rel="noopener noreffer ">https://github.com/TNG/ArchUnit</a> <a class="star-note-link" href="/posts/2019-02-19-tng-archunit/" title="TNG/ArchUnit: my star note">★&nbsp;star&nbsp;note</a></p>]]></description></item><item><title>xunit</title><link>https://blog.emecas.net/posts/2019-02-19-xunit/</link><pubDate>Tue, 19 Feb 2019 10:19:18 -0500</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2019-02-19-xunit/</guid><description><![CDATA[<p>xUnit.net<br>
<a href="https://xunit.github.io/" target="_blank" rel="noopener noreffer ">https://xunit.github.io/</a><br>
xUnit.net is a free, open source, community-focused unit testing tool for the .NET Framework. Written by the original inventor of NUnit v2, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other .NET languages. xUnit.net works with ReSharper, CodeRush, TestDriven.NET and Xamarin. It is part of the .NET Foundation, and operates under their code of conduct. It is licensed under Apache 2 (an OSI approved license).</p>]]></description></item><item><title>Don't Measure Unit Test Code Coverage</title><link>https://blog.emecas.net/posts/2019-02-02-don-t-measure-unit-test-code-coverage/</link><pubDate>Sat, 02 Feb 2019 14:53:12 -0500</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2019-02-02-don-t-measure-unit-test-code-coverage/</guid><description><![CDATA[<p>Don&rsquo;t Measure Unit Test Code Coverage<br>
By James Shore<br>
01 Feb, 2019<br>
<a href="https://www.jamesshore.com/v2/blog/2019/dont-measure-unit-test-code-coverage" target="_blank" rel="noopener noreffer ">https://www.jamesshore.com/v2/blog/2019/dont-measure-unit-test-code-coverage</a></p>
<blockquote>
<p>If you&rsquo;re using test-driven development, don&rsquo;t measure unit test code coverage. It&rsquo;s worse than a useless statistic; it will actively lead you astray.</p>
</blockquote>
<p>What should you do instead? That depends on what you want to accomplish.</p>
<ul>
<li>To improve code and test practices: perform root-cause analysis of escaped defects, then improve your design and process to prevent that sort of defect from happening again</li>
<li>To improve programmer code quality: teach testing skills, speed up the test loop, refactor more, use evolutionary design, and try pairing or mobbing</li>
<li>To improve test discipline: use coaching and discipline-enhancing practices such as pairing or mobbing</li>
<li>To add tests to legacy code: nurture a habit of adding tests as part of working on any code</li>
<li>To improve requirements code quality: involve customer representatives early in the process</li>
<li>To improve non-functional quality: use a mix of real-world monitoring, fail-fast code, and specialized testbeds</li>
<li>(TDD reflexion) Here&rsquo;s the thing about TDD: any code you want to cover is ipso facto covered. If you&rsquo;re still getting defects, something else is wrong.</li>
</ul>
<hr>
<p><em>Source: commit <a href="https://github.com/emecas/My-Notes/commit/659e7c7d2383a4d347fc8f85f12272e48ffbaadc" target="_blank" rel="noopener noreffer "><code>659e7c7</code></a> in My-Notes, improved in <a href="https://github.com/emecas/My-Notes/commit/6cc6d0e312c3631b64e5bc52a4393e9a60787946" target="_blank" rel="noopener noreffer "><code>6cc6d0e</code></a> (2026-11-23).</em></p>]]></description></item><item><title>oracle/ktf</title><link>https://blog.emecas.net/posts/2017-12-26-oracle-ktf/</link><pubDate>Tue, 26 Dec 2017 15:03:12 +0000</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2017-12-26-oracle-ktf/</guid><description><![CDATA[<p>oracle/ktf<br>
Kernel Test Framework - a unit test framework for the Linux kernel<br>
Shell repository by oracle, created in 2017, with 96 stars and 36 forks. Archived by its owner. Starred on 2017-12-26.<br>
<a href="https://github.com/oracle/ktf" target="_blank" rel="noopener noreffer ">https://github.com/oracle/ktf</a></p>
<hr>
<p><em>Source: starred on GitHub on 2017-12-26: <a href="https://github.com/oracle/ktf" target="_blank" rel="noopener noreffer ">oracle/ktf</a>.</em></p>]]></description></item><item><title>Separating Unit from Integration tests in Java using Gradle</title><link>https://blog.emecas.net/posts/2017-08-17-separating-unit-from-integration-tests-in-java-using-gradle/</link><pubDate>Thu, 17 Aug 2017 13:34:03 -0400</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2017-08-17-separating-unit-from-integration-tests-in-java-using-gradle/</guid><description><![CDATA[<p>Modeling Web APIs: your best choices<br>
Comparing  : API Blueprint vs RAML vs Swagger<br>
<a href="http://modeling-languages.com/modeling-web-api-comparing/" target="_blank" rel="noopener noreffer ">http://modeling-languages.com/modeling-web-api-comparing/</a></p>
<p>Separating Unit from Integration tests in Java using Gradle<br>
<a href="http://www.stuartingram.com/2016/09/15/separating-unit-from-integration-tests-in-java-using-gradle/" target="_blank" rel="noopener noreffer ">http://www.stuartingram.com/2016/09/15/separating-unit-from-integration-tests-in-java-using-gradle/</a></p>
<hr>
<p><em>Source: commit <a href="https://github.com/emecas/My-Notes/commit/afa8f998bae1ec2bdf6e3b42351d53f413b357e8" target="_blank" rel="noopener noreffer "><code>afa8f99</code></a> in My-Notes.</em></p>]]></description></item><item><title>Test Project</title><link>https://blog.emecas.net/posts/2017-03-03-test-project/</link><pubDate>Fri, 03 Mar 2017 14:43:34 -0500</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2017-03-03-test-project/</guid><description><![CDATA[<p>Test Project Blog<br>
<a href="http://blog.testproject.io/" target="_blank" rel="noopener noreffer ">http://blog.testproject.io/</a><br>
TestProject’s blog is about providing you everything you need to know about test automation. We created this helpful platform in order to share interesting yet informative articles for any test automation enthusiast. Starting today, you can stay updated with news and latest trends, researches and best practice magazine articles on JavaScript, Selenium, Appium, unit testing, API, mobile testing etc.</p>
<hr>
<p><em>Source: commit <a href="https://github.com/emecas/My-Notes/commit/261889cf4e953a6fc45bda68112831079f98e47f" target="_blank" rel="noopener noreffer "><code>261889c</code></a> in My-Notes.</em></p>]]></description></item><item><title>Digital Units of Measure</title><link>https://blog.emecas.net/posts/2013-05-07-digital-units-of-measure/</link><pubDate>Tue, 07 May 2013 15:12:27 +0200</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2013-05-07-digital-units-of-measure/</guid><description><![CDATA[<p>Digital Units of Measure<br>
<a href="http://simple.be/tech/reference/bit" target="_blank" rel="noopener noreffer ">http://simple.be/tech/reference/bit</a><br>
yottabyte = 1 yottabyte<br>
= 1024 zettabytes<br>
= 1048576 exabytes<br>
= 1073741824 petabytes<br>
= 1099511627776 terabytes<br>
= 1125899906842624 gigabytes<br>
= 1152921504606846976 megabytes<br>
= 9223372036854775808 Megabits<br>
= 1180591620717411303424 kilobytes<br>
= 9444732965739290427392 Kilobits<br>
= 1208925819614629174706176 bytes<br>
= 2417851639229258349412352 nibbles<br>
= 9671406556917033397649408 bits</p>
<hr>
<p><em>Source: commit <a href="https://github.com/emecas/My-Notes/commit/e630effe1ce65188de1646dadf7c2dd3832bc61d" target="_blank" rel="noopener noreffer "><code>e630eff</code></a> in My-Notes.</em></p>]]></description></item></channel></rss>