As many others, I am new to Jenkins CI. But I am improving!
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++, but I can't seem to understand which plugin in Jenkins (perhaps xUnit?) and how to configure it.
Questions: What do I have to install and/or download? What do I have to put in all the fields? How do I do a get the unit test so it creates a report file in.... XML(?) Perhaps? Or other? Am I missing some sort of script? ( I have never done scripts). Or is it just to run my local unit test, but through Jenkins?
I would love a video tutorial for this. I have only found tutorials for Visual Studio CSharp, and that is not what I am looking for.
Thank you!
What do I have at the moment?
I have installed Jenkins at my localhost:8081. I have installed scm-manager for my repositories at my localhost:8082 (I am using GIT as source control) I have setup configuration/concection between my Jenkins project and my repository. The builds are triggered when pushed to master. This works fine.
When I do a clone I get these files with a Hello World program:
- helloworld.h
- helloworldTest.c
- A directory with the local unit test: simpleCtest (including the testfile tests.h)
I've downloaded that simpleCtest from http://ift.tt/1Po6dPR
helloworld.h
#include <stdio.h>
#include <stdlib.h>
//Declaration
const char * HelloWorld();
const char * HelloJenkins();
//Definitions
const char * HelloWorld(){
return "Hello World!";
}
const char * HelloJenkins(){
return "Hello Jenkins!";
}
helloworldTest.c
// 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("Hello Jenkins Test")
ASSERT_EQUALS("Hello Jenkins!", HelloJenkins())
END_TEST()
START_TEST("Count World")
ASSERT_EQUALS(12, strlen(HelloWorld()))
END_TEST()
START_TEST("Count Jenkins")
ASSERT_EQUALS(14, strlen(HelloJenkins()))
END_TEST()
// End the overall test suite
END_TESTS()
When I compile and run my test code in the command window I get this output (some warnings, but that is not important).
I also get this in Jenkins if I do the exact same command in Jenkins-> MyProject -> configuration -> Build -> Add build step: Execute Windows batch command
gcc helloworldTest.c (compile)
a (execute)
**gcc helloworldTest.c**
In file included from helloworldTest.c:2:0:
helloworldTest.c: In function 'main':
helloworldTest.c:20:21: warning: incompatible implicit declaration of built-in function 'strlen' [enabled by default]
ASSERT_EQUALS(12, strlen(HelloWorld()))
^
simplectest/tests.h:244:7: note: in definition of macro 'ASSERT'
if(!(test)) { \
^
helloworldTest.c:20:3: note: in expansion of macro 'ASSERT_EQUALS'
ASSERT_EQUALS(12, strlen(HelloWorld()))
^
helloworldTest.c:25:21: warning: incompatible implicit declaration of built-in function 'strlen' [enabled by default]
ASSERT_EQUALS(14, strlen(HelloJenkins()))
^
simplectest/tests.h:244:7: note: in definition of macro 'ASSERT'
if(!(test)) { \
^
helloworldTest.c:25:3: note: in expansion of macro 'ASSERT_EQUALS'
ASSERT_EQUALS(14, strlen(HelloJenkins()))
^
**a**
> Hello World Test...
> Hello Jenkins Test...
> Count World...
> Count Jenkins...
--- Results ---
Tests run: 4
Passes: 4
Failures: 0
... Later I also would want to setup code coverage for this. But that is a future issue.
Aucun commentaire:
Enregistrer un commentaire