title: Unit Testing and in C with Jenkins CI automated builds
body: <p>As many others, I am new to Jenkins CI. But I am improving!</p>
  
  <p>So... I have setup a build server at work, with Windows Server 2012 r2.
  I am trying to setup a unit test in Jenkins for my simple C code in Notepad++.</p>
  
  <p>I have written my own helloworldTest.c with simpleCtest as unit test framework (see below).</p>
  
  <p>Q1: Am I supposed to use this test, executing the binary file?</p>
  
  <p>Q2: If so..
  How do I "publish my test result"? Is this where I need to use a plugin from Jenkins, such as <a href="https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin" rel="nofollow">xUnit</a>? How? (I am seeing something about a xml-file...)
  If not.. I would like to get some ideas, please.</p>
  
  <p>Q3: I have stumbled upon <strong>gcovr.com</strong> in my searches about unit tests. Is this just another way? Why/How?</p>
  
  <p>I will later on continue with setup code coverage. But I do not know if that will be effected by the choices above.</p>
  
  <hr>
  
  <p><em>What I have at the moment</em></p>
  
  <p>I have installed Jenkins at my localhost:8081.
  I have installed scm-manager for my repositories at my localhost:8082.
  I have setup configuration/connection between my Jenkins project and my repository. The builds are triggered when pushed to master. This works fine.</p>
  
  <p>My Hello World project includes:</p>
  
  <ul>
  <li>helloworld.h</li>
  <li>helloworldTest.c</li>
  <li>A directory with the local unit test: simpleCtest (including the testfile tests.h)</li>
  </ul>
  
  <p>These will show in my Jenkins Project workspace as well.</p>
  
  <p>I've downloaded that simpleCtest unit test framework from <strong>simplectest.sourceforge.net</strong></p>
  
  <p><strong>helloworld.h</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  //Declaration
  const char * HelloWorld();
  
  //Definitions
  const char * HelloWorld(){
       return "Hello World!";
  }
  </code></pre>
  
  <p><strong>helloworldTest.c</strong></p>
  
  <pre><code>// include test definitions
  #include "simplectest/tests.h"
  #include "helloworld.h"
  
  // Start the overall test suite
  START_TESTS()
  
      START_TEST("Hello World Test")
         ASSERT_EQUALS("Hello World!", HelloWorld())
      END_TEST()
  
      START_TEST("Count World")
          ASSERT_EQUALS(12, strlen(HelloWorld()))
      END_TEST()
  
  // End the overall test suite
  END_TESTS()
  </code></pre>
  
  <p>I execute the binary testfile helloworldTest in Jenkins-> MyProject -> configuration -> Build -> Add build step: Execute Windows batch command</p>
  
  <p>I get this output </p>
  
  <pre><code>&gt; Hello World Test...
  &gt; Count World...
  
  --- Results ---
  Tests run:    2
  Passes:       2
  Failures:     0
  </code></pre>
  
  <p>If all tests pass, Jenkins Build Success (blue ball), if any test fails the Build fails (red ball).</p>