{"id":7856,"date":"2023-06-20T14:49:39","date_gmt":"2023-06-20T12:49:39","guid":{"rendered":"https:\/\/medtech-ingenieur.de\/?p=7856"},"modified":"2023-08-02T14:39:27","modified_gmt":"2023-08-02T12:39:27","slug":"unit-testen-c","status":"publish","type":"post","link":"https:\/\/medtech-ingenieur.de\/en\/unit-testen-c\/","title":{"rendered":"Introduction to Unit Testing in C# for Beginners \u2013 Setup, Basics, and Helpful Tools"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7943 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png\" alt=\"\" width=\"1366\" height=\"768\" srcset=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png 1366w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-300x169.png 300w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-768x432.png 768w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-1024x576.png 1024w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-100x56.png 100w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-150x84.png 150w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-200x112.png 200w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-450x253.png 450w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-600x337.png 600w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities-900x506.png 900w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><br \/>\nUnit tests are essential for software development. They help prevent errors that would otherwise be discovered late and difficult to locate. Visual Studio offers several extensions for C# developers to help us create unit tests.<\/p>\n<p>In this blog post, I&#039;ll guide you through the most important steps in setting up a test project: Using an example, I&#039;ll create a simple unit test, provide some useful tips, and introduce helpful tools. The prerequisite for readable and effective unit tests is that the individual components of the code can be tested independently of the rest of the software.<\/p>\n<p>You can learn how to make your code testable using interfaces in my next blog post, \u201cInterfaces for better unit testing.\u201d<\/p>\n<h2>Why should you perform unit tests?<\/h2>\n<ul>\n<li>Ensuring the functionality of classes and methods.<\/li>\n<li>Simplifies the search for errors because certain sections of the code are covered by unit tests and can be excluded as a source of errors.<\/li>\n<li>After adjusting methods or classes, you can quickly and easily determine whether the functionality is still available.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Basics of unit tests<\/h2>\n<p>When creating unit tests, the following should be considered:<\/p>\n<ul>\n<li>To create meaningful unit tests, the individual components must be testable independently of each other. How to ensure the testability of your code with interfaces is explained using an example in the blog post &quot;Interfaces for Better Unit Testing.&quot;<\/li>\n<li>A unit test always tests exactly one function.<\/li>\n<li>The input parameters and the desired result must be known in order to check the function for correctness.<\/li>\n<li>For each constraint of a function, a unit test must be created to cover all possible scenarios for which this function can be used.<\/li>\n<\/ul>\n<h4>Structure of a unit test<\/h4>\n<p>There are a few points to consider when creating structured and readable unit tests:<\/p>\n<ul>\n<li>A test method is written for each scenario.<\/li>\n<li>The name of the test method contains which method is being tested and what it is being tested for.<\/li>\n<li>The name of the test method ends with the word \u201cShould\u201d.<\/li>\n<li>Example: the test method for the function Calc(int n1, int n2) which adds two numbers could be named Calc::AddTwoNumbersShould()<\/li>\n<li>A test can usually be divided into three blocks<\/li>\n<\/ul>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li><strong>Arrange:<\/strong><br \/>\n\u2013 Preparation of the input parameters<br \/>\n\u2013 Determine the desired result<br \/>\n\u2013 Creating objects for testing<\/li>\n<li><strong>Act:<\/strong><br \/>\n\u2013 Execution of the function to be tested<br \/>\n\u2013 Act usually consists of only a single line<\/li>\n<li><strong>Assert:<\/strong><br \/>\n\u2013 Checking the results<br \/>\n\u2013 Check whether exceptions were thrown<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>This division makes your tests more readable and understandable, because you can see at a glance what the input parameters and expected results are (Arrange block), what is being tested (Act block), and why the test fails (Assert block).<\/p>\n<p>&nbsp;<\/p>\n<h2>Example of unit testing a method for a calculator<\/h2>\n<p>The following steps are described<\/p>\n<ol>\n<li>Set up<\/li>\n<li>The class to be tested: Calculator<\/li>\n<li>How do you create a test project?<\/li>\n<li>How do you create a test class?<\/li>\n<li>Adding the reference to the project to be tested<\/li>\n<li>Creating a test<br \/>\na. What can be tested?<\/li>\n<li>Running a test<br \/>\na. with the test explorer<br \/>\nb. with axocover<\/li>\n<\/ol>\n<p><strong>1. Setup<\/strong><br \/>\nIn the following example the following setup was used<\/p>\n<ul>\n<li>Visual Studio 2019<\/li>\n<li>NUnitTest: VisualStudio -&gt; Tools -&gt; NuGet package<br \/>\nNUnit v3.13.3<br \/>\no NUnit3TestAdapter v.4.4.<\/li>\n<li>Aoxcover: VisualStudio -&gt; Tools -&gt; Extensions and Updates<br \/>\no AxoCover v 1.1.7.0<\/li>\n<\/ul>\n<p><strong>2. The class to be tested: Calculator<\/strong><br \/>\nFor this example, we will test the method Calc(int n1, int n2) of the Calculator class, which is shown in Figure 1. Here, we will limit ourselves to addition only.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1.png\" alt=\"\" width=\"605\" height=\"499\" srcset=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1.png 605w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-300x247.png 300w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-100x82.png 100w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-150x124.png 150w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-200x165.png 200w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-450x371.png 450w, https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild1-1-600x495.png 600w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 1: Class to be tested<\/figcaption><\/figure>\n<p><strong>3. Create a test project<\/strong><br \/>\nCreate a second project of type \u201cNUnit 3 Unit Test Project\u201d in the solution folder.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild2-1.png\" alt=\"\" width=\"605\" height=\"420\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 2: Creating a test project<\/figcaption><\/figure>\n<p><strong>4. Create a test class<\/strong><br \/>\nNow create a new test class in your new test project. Select the &quot;NUnit Test Fixture&quot; type and name it after the class or function you want to test. In the following, the name &quot;CalcShould&quot; was used.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild3-1.png\" alt=\"\" width=\"605\" height=\"420\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 3: Creating a test class<\/figcaption><\/figure>\n<p>In the newly created test fixture, a first test method TestMethod() is automatically created, as shown in Figure 4.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild4-1.png\" alt=\"\" width=\"605\" height=\"370\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 4: Automatically created test class<\/figcaption><\/figure>\n<p><strong>5. Adding the reference to the project to be tested<\/strong><br \/>\nTo access the classes from your actual project, you first need to add a reference to your project. To do this, right-click on the references of your test project and select &quot;Add References.&quot; Then add your project.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild5-1.png\" alt=\"\" width=\"600\" height=\"400\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 5: Adding the reference to the project to be tested<\/figcaption><\/figure>\n<p>Now you can add a using directive to your main project in your test fixture. You can now access the class you&#039;re testing.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild6-1.png\" alt=\"\" width=\"600\" height=\"400\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 6: Adding the Using directive to the project to be tested in the test fixture<\/figcaption><\/figure>\n<p><strong>6. Creating a test<\/strong><br \/>\nFigure 7 shows a test method that tests the Calc method of the Calculator class. This method only tests the addition of two natural numbers.<\/p>\n<p>Arrange:<\/p>\n<p style=\"text-indent: 10px;\">In the Arrange block, an object of the Calculator class is created and the input parameters number1 and number2, as well as the expected result resultShould, are specified.<\/p>\n<p>Act:<\/p>\n<p style=\"text-indent: 10px;\">In the Act block, the Calc method is executed with the appropriate input parameters and the result is stored in the variable result.<\/p>\n<p>Assert:<\/p>\n<p style=\"text-indent: 10px;\">The Assert block checks whether the result match the expected result resultShould.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild7-1.png\" alt=\"\" width=\"600\" height=\"330\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 7: Unit test for the Calc method for adding two integers<\/figcaption><\/figure>\n<p><strong>What can be tested in a unit test?<\/strong><br \/>\nBelow are some helpful ways to use the Assert class in unit tests.<\/p>\n<table>\n<tbody>\n<tr>\n<th>Using Assert<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<tr>\n<td>Assert.That() Is.Equal(var x, var y)<\/td>\n<td>Test can only be passed if x has the same value as y<\/td>\n<\/tr>\n<tr>\n<td>Assert.Fail()<\/td>\n<td>The test can only pass if the code fails before reaching this line. For example, because an unhandled exception is thrown beforehand.<\/td>\n<\/tr>\n<tr>\n<td>Assert.That(x, Is.GreaterThan(y));<\/td>\n<td>The test can only be passed if x is greater than y<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Other ways to use Asser:<br \/>\n<a href=\"https:\/\/docs.nunit.org\/articles\/nunit\/writing-tests\/assertions\/assertions.html\">https:\/\/docs.nunit.org\/articles\/nunit\/writing-tests\/assertions\/assertions.html<\/a><\/p>\n<p><strong>7. Run a unit test<\/strong><br \/>\nNow that our test project is created and the first test is implemented, we need to run it. We can do this using Visual Studio&#039;s Test Explorer or the Axocover package.<\/p>\n<p><strong>Running tests with the Test Explorer<\/strong><\/p>\n<p>Visual Studio has its own Test Explorer for running tests. To use it, click Test -&gt; Window -&gt; Test Explorer. The Test Explorer will open and display all the tests in your solution. By clicking &quot;Run All,&quot; you can run all your tests at once. Passing tests will be highlighted in green.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 360px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild8.png\" alt=\"\" width=\"360\" height=\"180\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 8: Running the test with the Test Explorer<\/figcaption><\/figure>\n<p><strong>Run tests with Axocover<\/strong><br \/>\nLike Test Explorer, Axocover also allows us to run single or multiple tests at once and then shows us the results<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 390px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild9.png\" alt=\"\" width=\"390\" height=\"330\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 9: Running the test with AxoCover<\/figcaption><\/figure>\n<p>However, it also has a coverage function. Instead of running the tests normally, tests can also be &quot;covered.&quot; The selected tests are then executed, and all lines of code that were run for the tests are highlighted in green to the right of the line numbering.<br \/>\nAll lines that were not tested are highlighted in red. Figure 10 shows that all lines of the test were tested. More interesting for developers, however, is that Figure 11 shows that only the lines of our Calculator class under test that were tested are highlighted in green. Only the addition case was highlighted in green, and no other lines.<\/p>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild10.png\" alt=\"\" width=\"600\" height=\"300\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 10: Coverage of the test method<\/figcaption><\/figure>\n<figure id=\"attachment_7878\" aria-describedby=\"caption-attachment-7878\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7878 size-full\" src=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Bild11.png\" alt=\"\" width=\"600\" height=\"600\" \/><figcaption id=\"caption-attachment-7878\" class=\"wp-caption-text\">Figure 11: Coverage of the tested method<\/figcaption><\/figure>\n<p>This feature is very useful for locating bugs in failed test runs or for verifying that tests cover all possible scenarios for a method. However, covering takes significantly longer than a normal test run and should therefore be used selectively.<\/p>\n<p>&nbsp;<\/p>\n<h3>Conclusion<\/h3>\n<p>NUnit allows us to create test projects and test fixtures to test individual classes or parts of a C# project. To test a function or class, one unit test should always be created per scenario, which should be divided into the three blocks Arrange, Act, and Assert.<br \/>\nIn the Assert block, the Assert class can be used to check whether results match, whether exceptions were thrown, and much more. Finally, we demonstrated how to use Axocover and the Coverage function to check which lines of our code were executed for a test.<\/p>","protected":false},"excerpt":{"rendered":"<p>Unittests sind f\u00fcr die Entwicklung von Software unerl\u00e4sslich. Mit ihnen lassen sich Fehler vermeiden, welche sonst erst sp\u00e4t auffallen w\u00fcrden und schwer zu lokalisieren w\u00e4ren. F\u00fcr C# Entwickler bietet Visual Studio einige Extensions, die uns bei der Erstellung von Unittests unterst\u00fctzen. In diesem Blogeintrag f\u00fchre ich dich durch die wichtigsten Schritte beim Einrichten eines Testprojektes: [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":7943,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7,468,8,205],"tags":[650,649,38,250,251,648],"class_list":["post-7856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","category-systemarchitekten","category-testen","category-tools","category-usability","tag-anfaenger","tag-c","tag-software","tag-softwaretest","tag-unit-test","tag-unittests","post-wrapper","thrv_wrapper"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/medtech-ingenieur.de\/en\/unit-testen-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH\" \/>\n<meta property=\"og:description\" content=\"Unittests sind f\u00fcr die Entwicklung von Software unerl\u00e4sslich. Mit ihnen lassen sich Fehler vermeiden, welche sonst erst sp\u00e4t auffallen w\u00fcrden und schwer zu lokalisieren w\u00e4ren. F\u00fcr C# Entwickler bietet Visual Studio einige Extensions, die uns bei der Erstellung von Unittests unterst\u00fctzen. In diesem Blogeintrag f\u00fchre ich dich durch die wichtigsten Schritte beim Einrichten eines Testprojektes: [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/medtech-ingenieur.de\/en\/unit-testen-c\/\" \/>\n<meta property=\"og:site_name\" content=\"MEDtech Ingenieur GmbH\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/medtechIngenieur\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-20T12:49:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-02T12:39:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alisa Schulz\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MedtechIng\" \/>\n<meta name=\"twitter:site\" content=\"@MedtechIng\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alisa Schulz\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/\"},\"author\":{\"name\":\"Alisa Schulz\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#\\\/schema\\\/person\\\/3c1800422d500e3f54ac7baa2c493948\"},\"headline\":\"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools\",\"datePublished\":\"2023-06-20T12:49:39+00:00\",\"dateModified\":\"2023-08-02T12:39:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/\"},\"wordCount\":1510,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Affordable-homes-in-thriving-communities.png\",\"keywords\":[\"anf\u00e4nger\",\"c#\",\"Software\",\"Softwaretest\",\"Unit Test\",\"unittests\"],\"articleSection\":[\"Software\",\"Systems Engineering\",\"Testen\",\"Tools\",\"Usability\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/\",\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/\",\"name\":\"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Affordable-homes-in-thriving-communities.png\",\"datePublished\":\"2023-06-20T12:49:39+00:00\",\"dateModified\":\"2023-08-02T12:39:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Affordable-homes-in-thriving-communities.png\",\"contentUrl\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Affordable-homes-in-thriving-communities.png\",\"width\":1366,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/unit-testen-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/medtech-ingenieur.de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#website\",\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/\",\"name\":\"MEDtech Ingenieur GmbH\",\"description\":\"Ingenieursdienstleister f\u00fcr Medizintechnik\",\"publisher\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#organization\"},\"alternateName\":\"MEDtech\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/medtech-ingenieur.de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#organization\",\"name\":\"MEDtech Ingenieur\",\"alternateName\":\"MEDtech\",\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/logo-700x700-1.png\",\"contentUrl\":\"https:\\\/\\\/medtech-ingenieur.de\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/logo-700x700-1.png\",\"width\":700,\"height\":700,\"caption\":\"MEDtech Ingenieur\"},\"image\":{\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/medtechIngenieur\",\"https:\\\/\\\/x.com\\\/MedtechIng\",\"https:\\\/\\\/www.instagram.com\\\/medtech.ingenieure\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/37871229\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/medtech-ingenieur.de\\\/#\\\/schema\\\/person\\\/3c1800422d500e3f54ac7baa2c493948\",\"name\":\"Alisa Schulz\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g\",\"caption\":\"Alisa Schulz\"},\"url\":\"https:\\\/\\\/medtech-ingenieur.de\\\/en\\\/author\\\/alisa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH","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:\/\/medtech-ingenieur.de\/en\/unit-testen-c\/","og_locale":"en_US","og_type":"article","og_title":"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH","og_description":"Unittests sind f\u00fcr die Entwicklung von Software unerl\u00e4sslich. Mit ihnen lassen sich Fehler vermeiden, welche sonst erst sp\u00e4t auffallen w\u00fcrden und schwer zu lokalisieren w\u00e4ren. F\u00fcr C# Entwickler bietet Visual Studio einige Extensions, die uns bei der Erstellung von Unittests unterst\u00fctzen. In diesem Blogeintrag f\u00fchre ich dich durch die wichtigsten Schritte beim Einrichten eines Testprojektes: [&hellip;]","og_url":"https:\/\/medtech-ingenieur.de\/en\/unit-testen-c\/","og_site_name":"MEDtech Ingenieur GmbH","article_publisher":"https:\/\/www.facebook.com\/medtechIngenieur","article_published_time":"2023-06-20T12:49:39+00:00","article_modified_time":"2023-08-02T12:39:27+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png","type":"image\/png"}],"author":"Alisa Schulz","twitter_card":"summary_large_image","twitter_creator":"@MedtechIng","twitter_site":"@MedtechIng","twitter_misc":{"Written by":"Alisa Schulz","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#article","isPartOf":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/"},"author":{"name":"Alisa Schulz","@id":"https:\/\/medtech-ingenieur.de\/#\/schema\/person\/3c1800422d500e3f54ac7baa2c493948"},"headline":"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools","datePublished":"2023-06-20T12:49:39+00:00","dateModified":"2023-08-02T12:39:27+00:00","mainEntityOfPage":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/"},"wordCount":1510,"commentCount":0,"publisher":{"@id":"https:\/\/medtech-ingenieur.de\/#organization"},"image":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#primaryimage"},"thumbnailUrl":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png","keywords":["anf\u00e4nger","c#","Software","Softwaretest","Unit Test","unittests"],"articleSection":["Software","Systems Engineering","Testen","Tools","Usability"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/medtech-ingenieur.de\/unit-testen-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/","url":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/","name":"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools - MEDtech Ingenieur GmbH","isPartOf":{"@id":"https:\/\/medtech-ingenieur.de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#primaryimage"},"image":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#primaryimage"},"thumbnailUrl":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png","datePublished":"2023-06-20T12:49:39+00:00","dateModified":"2023-08-02T12:39:27+00:00","breadcrumb":{"@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/medtech-ingenieur.de\/unit-testen-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#primaryimage","url":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png","contentUrl":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2023\/06\/Affordable-homes-in-thriving-communities.png","width":1366,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/medtech-ingenieur.de\/unit-testen-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/medtech-ingenieur.de\/"},{"@type":"ListItem","position":2,"name":"Einf\u00fchrung ins Unit-Testen in C# f\u00fcr Anf\u00e4nger \u2013 Setup, Basics und hilfreiche Tools"}]},{"@type":"WebSite","@id":"https:\/\/medtech-ingenieur.de\/#website","url":"https:\/\/medtech-ingenieur.de\/","name":"MEDtech Ingenieur GmbH","description":"Engineering service provider for medical technology","publisher":{"@id":"https:\/\/medtech-ingenieur.de\/#organization"},"alternateName":"MEDtech","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/medtech-ingenieur.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/medtech-ingenieur.de\/#organization","name":"MEDtech Engineer","alternateName":"MEDtech","url":"https:\/\/medtech-ingenieur.de\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/medtech-ingenieur.de\/#\/schema\/logo\/image\/","url":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2024\/01\/logo-700x700-1.png","contentUrl":"https:\/\/medtech-ingenieur.de\/wp-content\/uploads\/2024\/01\/logo-700x700-1.png","width":700,"height":700,"caption":"MEDtech Ingenieur"},"image":{"@id":"https:\/\/medtech-ingenieur.de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/medtechIngenieur","https:\/\/x.com\/MedtechIng","https:\/\/www.instagram.com\/medtech.ingenieure\/","https:\/\/www.linkedin.com\/company\/37871229\/"]},{"@type":"Person","@id":"https:\/\/medtech-ingenieur.de\/#\/schema\/person\/3c1800422d500e3f54ac7baa2c493948","name":"Alisa Schulz","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/12cc2ec96702ad3d6669a851c07c9d09d71c8318e25533a7a1491b7f510ec69b?s=96&d=mm&r=g","caption":"Alisa Schulz"},"url":"https:\/\/medtech-ingenieur.de\/en\/author\/alisa\/"}]}},"_links":{"self":[{"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/posts\/7856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/comments?post=7856"}],"version-history":[{"count":23,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/posts\/7856\/revisions"}],"predecessor-version":[{"id":7948,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/posts\/7856\/revisions\/7948"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/media\/7943"}],"wp:attachment":[{"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/media?parent=7856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/categories?post=7856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/medtech-ingenieur.de\/en\/wp-json\/wp\/v2\/tags?post=7856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}