0

first of all I will show you how the program is structured:

enter image description here

I built the solution using jenkins as shown in the figure below enter image description here

this is a cpp program. I do not know how to run unit test since there is no .exe file for unit test.

here is the .obj and .dll files in unit test folder enter image description here

I know I should use MSbuild but I cannot find any thing that tells me how to run unittest on jenkins

Shahin
  • 25
  • 3

1 Answers1

0

Gold Rule #1 in devops

The steps should work in your localhost preferable on Linux and using the shell, before port it to Jenkins. If it don't work even on your localhost, Jenkins can't do anything.

Then if it works in your localhost (all the shells and installed tools required) , in jenkins you could use on of these approaches:

  1. Jenkins shell script
  2. Some Jenkins plugin to avoid the shell or scripts

Gold Rule #2 in devops

Use the shell, not programs with user interface , sometimes called IDEs. Devops flows for build, test, deploy are executed in the background and the 99.999% on Linux, not windows

c++ build

Reviewing, cmkake is used to build c++ applications. Also some others tools:

  • g++
  • make
  • cc
  • gcc

More details here: How to compile a c++ program in Linux?

Here a sample with g++

# compile
g++ ./foo/bar.cpp -o ./foo/bar
# this will generate an executable file ./foo/bar ready to be used

Since you have several files, you only need to append the files to the g++ according to:

https://stackoverflow.com/a/30064940/3957754

unit test

Depending of the classification (compiled/interpreted), execute a unit test is just to run a file:

java

  • mvn clean test

Searches all *Test.java files and if the files has the @Test annotation, the file is executed

nodejs

  • node /foo/bar/test.js
  • jest ...
  • mocha 'src/test/**/*.test.js'

Similar to java but with *.test.js files

As you can see, unit test is just to execute a file some times compiled previously or directly execution. So in your case, since c++ is a compiled language, to run your test , you only need

# compile
g++ ./UnitTest/UnitTest.cpp -o ./UnitTest/UnitTest

# run
./UnitTest/UnitTest

Visual Studio

This tool is for c#. If you read the previous paragraphs, you don't need complicated tools to build c++ projects.

Windows

You only need to choose one tool, install it on your windows, open the CMD shell or powershell and try the commands

  • g++
  • make
  • cc
  • gcc

If it works, go to your jenkins and use the shell step

References

JRichardsz
  • 14,356
  • 6
  • 59
  • 94