{"id":21920,"date":"2017-01-30T10:00:50","date_gmt":"2017-01-30T15:00:50","guid":{"rendered":"https:\/\/simpleprogrammer.com\/?p=21920"},"modified":"2017-10-28T18:23:02","modified_gmt":"2017-10-28T22:23:02","slug":"tdd-unit-testing","status":"publish","type":"post","link":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/","title":{"rendered":"What is TDD? What is Unit Testing?"},"content":{"rendered":"<p>I have a love \/ hate relationship with test driven development and unit testing.\\n\\nI\u2019ve been both an ardent supporter of these \u201cbest practices,\u201d but I\u2019ve also been more than skeptical of their use.\\n\\n<strong>One of the big problems in software development is when developers\u2014or sometimes managers\u2014who mean well <a href=\"https:\/\/simpleprogrammer.com\/2010\/04\/17\/when-doing-the-right-thing-is-wrong\/\">apply \u201cbest practices\u201d simply because they are best practices<\/a> and <a href=\"https:\/\/simpleprogrammer.com\/2013\/02\/17\/principles-are-timeless-best-practices-are-fads\/\">don\u2019t understand their reason or actual use<\/a>.<\/strong>\\n\\nI remember working on one such software project where I was informed that the software we were going to be modifying had a huge number of unit tests\u2013\u2013around 3,000.\\n\\nNormally this is a good sign.\\n\\nThis probably means the developers on the project implemented other best practices as well, and there is going to be some semblance of structure or meaningful architecture within the code base.\\n\\nI was excited to hear this news since it meant that my job as the mentor \/ coach for the development team was going to be easier. Since we already had unit tests in place, all I had to do was get the new team to maintain them and start writing their own.\\n\\nI opened up my IDE and loaded the project into it.\\n\\nIt was a <em>big <\/em>project.\\n\\nI saw a folder labeled \u201cunit tests.\u201d\\n\\nGreat. Let\u2019s run them and see what happens.\\n\\nIt only took a few minutes and\u2014much to my surprise\u2014all the tests ran and everything was green. They <em>all<\/em> passed.\\n\\nNow I really became skeptical. <strong>Three thousand unit tests, and they all passed?<\/strong>\\n\\nWhat is going on here?\\n\\nMost of the time when I am first pulled onto a development team to help coach them, there are a bunch of failing tests if there are any unit tests at all.\\n\\nI decided to spot check one test at random.\\n\\nAt first glance, it seemed reasonable enough.\\n\\nIt wasn\u2019t the best, most explanative test I\u2019d ever seen, but I could make out what it was doing.<img loading=\"lazy\" decoding=\"async\" class=\" wp-image-21923 alignright\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Testing.png\" alt=\"\" width=\"354\" height=\"354\" \/>\\n\\nBut then I noticed something\u2026\\n\\n<strong>There was no assert.<\/strong>\\n\\n<a href=\"https:\/\/simpleprogrammer.com\/2010\/03\/05\/the-ego-test\/\">Nothing was actually being tested<\/a>.\\n\\nThe test had steps and those steps were running, but at the end of the test where it is supposed to check something, there was no check.\\n\\nThe \u201ctest\u201d wasn\u2019t testing anything.\\n\\nI opened up another test.\\n\\nWorse.\\n\\nThe assert statement, which was testing something at some point, was commented out.\\n\\n<strong>Wow, that\u2019s a great way to make a test pass; just comment out the code that\u2019s making it fail.<\/strong>\\n\\nI checked test after test.\\n\\nNone of them were testing anything.\\n\\nThree thousand tests and they were all worthless.\\n\\n<strong>There is a huge difference between writing unit tests and <a href=\"https:\/\/simpleprogrammer.com\/2010\/10\/15\/the-purpose-of-unit-testing\/\">understanding unit testing<\/a> and test-driven development.<\/strong>\\n\\n<\/p>\n<h2>What Is Unit Testing?<\/h2>\n<p>\\n\\nThe basic idea of unit testing is to <strong>write tests which exercise the smallest \u201cunit\u201d of code possible.<\/strong>\\n\\nUnit tests are typically written in the same programming language as the source code of the application itself and written to utilize that code directly.\\n\\nThink of unit tests as <strong>code that tests other code.<\/strong>\\n\\nWhen I use the word \u201ctest\u201d here, I\u2019m using it fairly liberally because <strong>unit tests aren\u2019t really tests.<\/strong> They don\u2019t test anything.\\n\\nWhat I mean by this is that when you run a unit test, you don\u2019t typically find out that some code doesn\u2019t work.\\n\\nIt\u2019s when you <em>write<\/em> a unit test that you find that information out.\\n\\nYes, the code could change later and that test could fail, so in that sense, a unit test is a regression test. In general, however, a unit test is not like a regular test where you have some steps you are going to execute and you see whether the software behaves correctly or not.\\n\\nAs a developer writing a unit test, <strong>you discover whether the code does what it is supposed to or not while you are writing the unit test<\/strong> because you are going to be continually modifying the code until the unit test passes.\\n\\nWhy would you write a unit test and not make sure that unit test passes?\\n\\nWhen you think about it this way, unit testing is more about specifying absolute requirements for specific units of code at a very low level.\\n\\n<strong>You can think of a unit test as an absolute specification.<\/strong>\\n\\nThe unit test specifies that under these conditions with this specific set of input, this is the output that I should get from this unit of code.\\n\\nTrue unit testing tests the smallest cohesive unit of code possible, which in most programming languages\u2014at least object oriented ones\u2014is a class.\\n\\n<\/p>\n<h2>What Is Sometimes Called Unit Testing?<\/h2>\n<p>\\n\\n<strong>Oftentimes, unit testing is confused with integration testing.<\/strong>\\n\\nSome \u201cunit tests\u201d test more than one class or test larger units of code.\\n\\nPlenty of developers will argue that these are still unit tests since they are whitebox tests written in code at a low level.\\n\\nYou shouldn\u2019t argue with these people.\\n\\nJust know in your mind that these are really integration tests and that true unit tests test the smallest unit of code possible in isolation.\\n\\nAnother thing that is often called unit testing\u2014but isn\u2019t really anything at all\u2014is writing unit tests that have no assert. In other words, unit tests that don\u2019t actually test anything.\\n\\n<strong>Any test, unit test or not, should have some kind of check\u2014we call it an assertion\u2014at the end that determines whether it passes or fails.<\/strong>\\n\\nA test that always passes is useless.\\n\\nA test that always fails is useless.\\n\\n<\/p>\n<h2>The Value of Unit Testing<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21925\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Unit-Testing-1-1024x576.png\" alt=\"\" width=\"747\" height=\"420\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Unit-Testing-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Unit-Testing-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Unit-Testing-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Unit-Testing-1.png 1280w\" sizes=\"auto, (max-width: 747px) 100vw, 747px\" \/>\\n\\nWhy am I such a stickler on unit testing?\\n\\nWhat is the harm in calling unit testing real testing and not testing the smallest unit in isolation?\\n\\nSo what if some of my tests don\u2019t have an assert? They are at least exercising the code.\\n\\nWell, let me try and explain.\\n\\n<strong><a href=\"https:\/\/simpleprogrammer.com\/2010\/10\/15\/the-purpose-of-unit-testing\/\">There are two major benefits, or reasons, to perform unit testing<\/a>.<\/strong>\\n\\nThe first one is to <strong>improve the design of the code.<\/strong>\\n\\nRemember how I said unit testing is not actually testing?\\n\\nWhen you write proper unit tests where you force yourself to isolate the smallest unit of code, <strong>you find problems in the design of that code.<\/strong>\\n\\nYou might find it extremely difficult to isolate the class and not include its dependencies, and that might make you realize that your code is too tightly coupled.\\n\\nYou might find that the basic functionality you are trying to test is spread out across multiple units, and that might make you realize that your code is not cohesive enough.\\n\\nYou might find that you sit down to write a unit test and you realize\u2014and believe me, this happens\u2014that <strong>you don\u2019t know what the code is supposed to do<\/strong>, so you can\u2019t write a unit test for it.\\n\\nAnd, of course, you might find an actual bug in the implementation of the code as the unit test forces you to think about some edge cases or test multiple inputs which you may not have accounted for.\\n\\n<strong>By writing unit tests and strictly adhering to having them test the smallest units of code in isolation, you find all kinds of problems with that code and the design of those units.<\/strong>\\n\\nIn the software development lifecycle, <strong>unit testing is more of an appraisal activity<\/strong> than a testing one.\\n\\nThe second main purpose of unit testing is to <strong>create an automated set of regression tests which can operate as a specification for the low level behavior of the software.<\/strong>\\n\\nWhat does that mean?\\n\\nWhen you change shit, you don\u2019t break shit.\\n\\nIn that way unit tests are tests: regression tests.\\n\\nBut the purpose of unit testing is not to merely build these regression tests.\\n\\n<strong>In the practical world, very few regressions are caught by unit tests <\/strong>since changing the unit of code you\u2019re testing almost always involves changing the unit test itself.\\n\\nRegression testing is much more effective at the higher level as a black box testing activity because, at that level, internal structure of the code could be changed while the external behavior is expected to remain the same.\\n\\n<strong>Unit tests test the internal structure, so when that structure changes, the unit tests don\u2019t \u201cfail.\u201d They become invalid and have to be changed, thrown out, or rewritten.<\/strong>\\n\\nNow you know more about the true purpose of unit testing than most 10-year software development veterans.\\n\\n<\/p>\n<h2>What Is Test-Driven Development (TDD)?<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21926\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Test-Driven-Develope-1-1024x576.png\" alt=\"\" width=\"761\" height=\"428\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Test-Driven-Develope-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Test-Driven-Develope-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Test-Driven-Develope-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Test-Driven-Develope-1.png 1280w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/>\\n\\nRemember the chapter where we talked about software development methodologies, and the waterfall methodology often didn\u2019t work out practically because we never had complete specifications up front?\\n\\n<strong>TDD is the idea that, before you write any code, you write a test that acts as a specification for exactly what that code is supposed to do.<\/strong>\\n\\n<a href=\"https:\/\/simpleprogrammer.com\/2014\/03\/27\/views-test-driven-development\/\">This is an extremely powerful concept in software development, but is often misused<\/a>.\\n\\nTDD usually means using unit tests to drive the creation of the production code being written, but it can be applied at any level.\\n\\nFor the purposes of this chapter, though, we are going to stick with the most common unit testing: application.\\n\\n<strong>TDD flips things around so that instead of writing the code first and then writing unit tests to test that code, (which we know isn\u2019t the case anyway), you are going to write the unit test first and then write just enough code to make that test pass.<\/strong>\\n\\nIn this way, the unit test is \u201cdriving\u201d the development of the code.\\n\\nThis process is repeated over and over.\\n\\nYou write another test that defines more functionality of what the code is supposed to do.\\n\\nYou change the code or add code to make the test pass.\\n\\nFinally, <a href=\"http:\/\/amzn.to\/2coV0DA\">you refactor the code<\/a>\u2014or clean it up\u2014to make it more succinct.\\n\\nThis is often called \u201cRed, Green, Refactor\u201d because at first the unit test fails (red), then code is written to make it pass (green), and finally the code is refactored.\\n\\n<\/p>\n<h2>What Is the Purpose of TDD?<\/h2>\n<p>\\n\\nJust like unit testing itself can be a best practice that is misapplied, TDD can be as well.\\n\\n<strong>It\u2019s very easy to call what you are doing TDD and to even follow the practice and not understand why you are doing it or the value\u2014if any\u2014it is providing.<\/strong>\\n\\n<strong>The biggest value of TDD is that tests happen to make excellent specifications.<\/strong>\\n\\nTDD is essentially the practice of writing unambiguous specifications, which can be automatically checked, before writing code.\\n\\nWhy are tests such great specifications?\\n\\nBecause <strong>they don\u2019t lie.<\/strong>\\n\\nThey don\u2019t tell you your code should work one way and then tell you after you spend two weeks pounding Mountain Dew and get everything working it should actually work another way and \u201cit\u2019s all wrong; that\u2019s not what I said at all.\u201d\\n\\nTests, if properly written, either pass or fail.\\n\\nTests specify in no uncertain terms exactly what should happen under a certain set of circumstances.\\n\\nSo, in that respect, we could say the purpose of TDD is to make sure we fully understand what we are implementing before we implement and that we \u201cgot it right.\u201d\\n\\n<strong>If you sit down to do TDD and you can\u2019t figure out what the test should test, it means you need to go ask more questions.<\/strong>\\n\\nThe other value of TDD is in keeping the code lean and succinct.\\n\\nCode is costly to maintain.\\n\\nI often joke that the best programmer is the one who writes the least code or even <a href=\"http:\/\/elegantcode.com\/2010\/06\/06\/the-best-code-you-will-ever-write\/\">finds way to delete code<\/a> because that programmer has found a surefire way to reduce errors and to decrease the maintenance cost of the application.\\n\\nBy utilizing TDD, you can be absolutely sure that you do not write any code that is not necessary since you will only ever write code to make tests pass.\\n\\nThere is a principle in software development called YAGNI, or you ain\u2019t going to need it.\\n\\nTDD prevents YAGNI.\\n\\n<\/p>\n<h2>A Typical TDD Workflow<\/h2>\n<p>\\n\\nIt can be a little difficult to understand TDD from a purely academic perspective, so let\u2019s explore what <a href=\"http:\/\/amzn.to\/2bNG4xA\">a sample TDD session<\/a> might look like.\\n\\nYou sit down at your desk and quickly sketch out what you think will be a high-level design of a feature to allow a user to login to the application and change their password if they forget it.\\n\\nYou decide that you are going to start off by first implementing the login functionality by creating a class that will handle all the logic for doing the login process.\\n\\nYou open up your favorite editor and create a unit test which is called \u201cEmpty login does not log user in.\u201d\\n\\nYou write the unit test code that first creates an instance of a Login class (which you haven\u2019t created yet).\\n\\nThen, you write some code to call a method on the Login class that passes in an empty username and password.\\n\\nFinally, you write an assertion, or assert, which asserts that the user is indeed not logged in.\\n\\nYou attempt to run the test, but it doesn\u2019t even compile because you don\u2019t have a Login class.\\n\\nYou remedy that situation by creating the Login class along with a method on that class for logging in and another for checking the status of a user to see if they are logged in.\\n\\nYou leave the functionality in this class and methods completely empty.\\n\\nYou run the test and this time it compiles, but quickly fails.\\n\\nNow, you go back and implement just enough functionality to make the test pass.\\n\\nIn this case, it would mean always returning that the user is not logged in.\\n\\nYou run the test again, and now it passes.\\n\\nOn to the next test.\\n\\nThis time you decide to write a test called \u201cUser is logged in when user has valid username and password.\u201d\\n\\nYou write a unit test that creates an instance of the Login class and try to login with a username and password.\\n\\nIn the unit test, you write an assertion that the Login class should say the user is logged in.\\n\\nYou run this new test, and of course it fails because your Login class always returns that the user is not logged in.\\n\\nYou go back to your Login class and implement some code to check for the user being logged in.\\n\\nIn this case, you\u2019ll have to figure out how to keep this unit test isolated.\\n\\nFor now, the simplest way to make this work is to hardcode the username and password you used in your test and if it matches, then you\u2019ll return that the user is logged in.\\n\\nYou make that change, run both tests, and they both pass.\\n\\nNow you look at the code you created, and see if there is a way you can refactor it to make it more simple.\\n\\nSo on you go, creating more tests, writing just enough code to make them pass, and then refactoring the code you wrote until there are no more test cases you can think of for the functionality you are trying to implement.\\n\\n<\/p>\n<h2>These Are Just the Basics<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21927\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Basic-1-1-1024x576.png\" alt=\"\" width=\"719\" height=\"404\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Basic-1-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Basic-1-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Basic-1-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/Basic-1-1.png 1280w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/>\\n\\nSo, there you have it.\\n\\n<strong>Those are the basics of TDD and unit testing\u2014<a href=\"https:\/\/simpleprogrammer.com\/2011\/01\/14\/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions\/\">but they are just the basics<\/a>.<\/strong>\\n\\nTDD can get a bit more complex when you truly try and isolate units of code because code is connected together.\\n\\nVery few classes exist in complete isolation.\\n\\n<a href=\"https:\/\/simpleprogrammer.com\/2010\/12\/12\/back-to-basics-why-unit-testing-is-hard\/\">Instead, they have dependencies, and those dependencies have dependencies and so on<\/a>.\\n\\nTo handle situations like these, veteran TDDers make use of mocks, which can help you to isolate individual classes by mocking the functionality of dependencies with pre-setup values.\\n\\nSince this is a basic overview of TDD and unit testing, we won\u2019t go into details here about mocks <a href=\"https:\/\/simpleprogrammer.com\/2011\/01\/23\/back-to-basics-unit-testing-without-mocks\/\">and other TDD techniques<\/a>, but just be aware that what I presented in this chapter is a somewhat simplified view.\\n\\nThe idea is to give you the basic concepts and the principles behind TDD and unit testing, which hopefully you now have.\\n\\n<\/p>\n<hr \/>\n<p>\\n\\n<a href=\"https:\/\/simpleprogrammer.com\/products\/careerguide\/\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/06\/Site-Ad.png\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a love \/ hate relationship with test driven development and unit testing.\\n\\nI\u2019ve been both an ardent supporter of these \u201cbest practices,\u201d but I\u2019ve also been more than skeptical of their use.\\n\\nOne of the big problems in software development is when developers\u2014or sometimes managers\u2014who mean well apply \u201cbest practices\u201d simply because they are best&#8230;<\/p>\n","protected":false},"author":2,"featured_media":21944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[162229812,31679,162229803,162229253,12,3882],"tags":[],"class_list":["post-21920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advice","category-process-improvement","category-programming","category-technical","category-testing","category-unit-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is TDD? What is Unit Testing? - Simple Programmer<\/title>\n<meta name=\"description\" content=\"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is TDD? What is Unit Testing? - Simple Programmer\" \/>\n<meta property=\"og:description\" content=\"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/\" \/>\n<meta property=\"og:site_name\" content=\"Simple Programmer\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-30T15:00:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-28T22:23:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"John Sonmez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Sonmez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/\"},\"author\":{\"name\":\"John Sonmez\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"headline\":\"What is TDD? What is Unit Testing?\",\"datePublished\":\"2017-01-30T15:00:50+00:00\",\"dateModified\":\"2017-10-28T22:23:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/\"},\"wordCount\":2851,\"commentCount\":5,\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/What-Is-Unity-Testing-1.png\",\"articleSection\":[\"Advice\",\"Process Improvement\",\"Programming\",\"Technical\",\"Testing\",\"Unit Testing\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/\",\"name\":\"What is TDD? What is Unit Testing? - Simple Programmer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/What-Is-Unity-Testing-1.png\",\"datePublished\":\"2017-01-30T15:00:50+00:00\",\"dateModified\":\"2017-10-28T22:23:02+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"description\":\"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#primaryimage\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/What-Is-Unity-Testing-1.png\",\"contentUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/What-Is-Unity-Testing-1.png\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/tdd-unit-testing\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/simpleprogrammer.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is TDD? What is Unit Testing?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/\",\"name\":\"Simple Programmer\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/simpleprogrammer.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\",\"name\":\"John Sonmez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"caption\":\"John Sonmez\"},\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/author\\\/jsonmez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is TDD? What is Unit Testing? - Simple Programmer","description":"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/","og_locale":"en_US","og_type":"article","og_title":"What is TDD? What is Unit Testing? - Simple Programmer","og_description":"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.","og_url":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/","og_site_name":"Simple Programmer","article_published_time":"2017-01-30T15:00:50+00:00","article_modified_time":"2017-10-28T22:23:02+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png","type":"image\/png"}],"author":"John Sonmez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Sonmez","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#article","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/"},"author":{"name":"John Sonmez","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"headline":"What is TDD? What is Unit Testing?","datePublished":"2017-01-30T15:00:50+00:00","dateModified":"2017-10-28T22:23:02+00:00","mainEntityOfPage":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/"},"wordCount":2851,"commentCount":5,"image":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png","articleSection":["Advice","Process Improvement","Programming","Technical","Testing","Unit Testing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/","url":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/","name":"What is TDD? What is Unit Testing? - Simple Programmer","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#primaryimage"},"image":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png","datePublished":"2017-01-30T15:00:50+00:00","dateModified":"2017-10-28T22:23:02+00:00","author":{"@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"description":"There is a huge difference between writing unit tests and understanding unit testing. I attempt to explain it in a way anyone can understand.","breadcrumb":{"@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simpleprogrammer.com\/tdd-unit-testing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#primaryimage","url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png","contentUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/01\/What-Is-Unity-Testing-1.png","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/simpleprogrammer.com\/tdd-unit-testing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simpleprogrammer.com\/"},{"@type":"ListItem","position":2,"name":"What is TDD? What is Unit Testing?"}]},{"@type":"WebSite","@id":"https:\/\/simpleprogrammer.com\/#website","url":"https:\/\/simpleprogrammer.com\/","name":"Simple Programmer","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simpleprogrammer.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67","name":"John Sonmez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","caption":"John Sonmez"},"url":"https:\/\/simpleprogrammer.com\/author\/jsonmez\/"}]}},"_links":{"self":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/21920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/comments?post=21920"}],"version-history":[{"count":0,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/21920\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media\/21944"}],"wp:attachment":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media?parent=21920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/categories?post=21920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/tags?post=21920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}