How to build ,compile and run eclipse Cute tests thru command prompt commands

Added by Anitha Lakshmi over 4 years ago

Hi,

I need to compile build and run cute tests project through command prompt or as batch file, Is there any way to go?
Please do the needful

Thanks & Regards,
Anitha


Replies (15)

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

Hi Anitha

If you have already created a CUTE executable project it should be fairly simple. Navigate to the project location and execute the following command:

g++ -I"./cute" -I"./boost" src/Test.cpp

Depending on your compiler you will need a different command. However, this should work for g++ and clang.

Regards
Thomas

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

Thanks for reply,
How to run using MINGW compiler?

Also I need a way to build, compile and run my cute test project which is in eclipse, to get output, using command prompt or batch file.

I have a scenario, Wher I will get daily builds, So I need a command or batch file, which will build,compile and run the eclipse cute test project and display result in some folder of project.

Please so the needful.

Thanks and Regards,
Anitha

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

The command I posted above also works for MinGW, as long as the corresponding g++ command is in the PATH environment variable.

The current version of CUTE creates an XML output, which can be passed as input of a test result view of a build server. Jenkins for example can handle such an test result file. Since CUTE is a header only framework you can integrate it easily into your existing build process, by just adding the necessary include path. This would be the -I"./cute" (and if required -I"./boost") part of the command I've posted before. Apart from that CUTE test source files can be compiled and integrated like any other c++ source file.

Regards
Thomas

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi,

This command worked for me, But when I run this command, I got an exe file, which is not opening.
Can I get any text folder for results.

Thanks & Regards,
Anitha

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

Well executing the exe should work, like executing any other executable. Running a plain CUTE test, like it is created by the latest version of the CUTE plug-in, containing the latest CUTE headers, the resulting output should be one failing test. Furthermore, it will create a <executable-name>.xml file, containing the test result.

What do you mean by "is not opening"? Does it crash? Does it produce any output?

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

Exe file is created, when I tried to open it , It will open and close within a second , I could not see what is happening.
Where exactly the XML file is created. I need path of the XML file.

Please do the needful.

Thanks and Regards,
Anitha

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

You could try running the exe in a console, which does not close automatically after completion.
The XML file is created at the location of the executable, if not otherwise specified.

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

Thank you so much, It worked by running the exe file. But I did not find the XML file.
Can I get code covergage report also, I am using Gcov,

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

You are welcome. I'm glad it worked.

It might be that you don't have the latest CUTE plug-in. Earlier versions did not contain the examples generating the XML output. You can easily check in the Test.cpp file. In a new executable CUTE test project the Test.cpp should look like this:

#include "cute.h" 
#include "ide_listener.h" 
#include "xml_listener.h" 
#include "cute_runner.h" 

void thisIsATest() {
    ASSERTM("start writing tests", false);    
}

void runAllTests(int argc, char const *argv[]){
    cute::suite s;
    //TODO add your test here
    s.push_back(CUTE(thisIsATest));
    cute::xml_file_opener xmlfile(argc,argv);
    cute::xml_listener<cute::ide_listener<> >  lis(xmlfile.out);
    cute::makeRunner(lis,argc,argv)(s, "AllTests");
}

int main(int argc, char const *argv[]){
    runAllTests(argc,argv);
    return 0;
}

The lines cute::xml_file_opener xmlfile(argc,argv); and cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); are responsible for creating the XML file. You can try using this Test.cpp as an example. If you can't compile this code, you need to get the latest version of the CUTE headers (version 2.0.0). They are available here: http://www.cute-test.com/projects/cute/wiki/CUTE_standalone or by updating to the latest version of the plug-in, which requires CDT 8.2.

Gcov is available, yet actually independent of the CUTE headers. The CUTE Gcov plug-in visualizes the Gcov output if the project is configured to do so. New C++ Project -> CUTE -> CUTE Project. On the second configuration page there is a checkbox Enable coverage analysis using gcov, if the plug-in is installed.

Regards
Thomas

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

You are right, I do not have latest version of cute, I tried to install thru eclipse update site, I am getting some error,
I will do it manually by downloading plugins.

Code coverage is working fine in eclipse, but I need a command for that to run in command prompt. Is that possible?
I need a command for coverage report, PMD.

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

Could you post the error you receive when trying to update the plug-in, please? That's something we might need to fix.

Using code coverage from console is independent of CUTE. You need to compile your program with two additional arguments (as long as it is a GCC compiler): -fprofile-arcs -ftest-coverage
This will create the .gcno file. For example Test.cgno. Executing the your programm will then yield the coverage file. For example Test.gcda. And there you have your coverage information.

Regards
Thomas

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

It worked for me. It was a proxy error.
I have one more doubt. Will CUTE support IAR complier.

Thanks & Regards,
Anitha

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

I'm glad it worked.

Regarding IAR: If it provides support for iostream and the required parts of boost are available (or the compiler supports C++11 alternatively) it should be possible. However, running the tests is a bit more complicated. Somehow the result must be retrievable. The Eclipse CDT plug-in requires the console output to display the unit test result window.

Perhaps Peter Sommerlad can shed some light on changing the output in CUTE.

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Anitha Lakshmi over 4 years ago

Hi Thomas,

It great to know that it will work with that IAR compiler. Thank you so much I will work on it and come up with much more questions.

Few more doubts :
1) Is there any command to get code coverage reports using Gcov, I want this coverage report in one folder, so I need a command , If I execute that command
I should get all coverage reports,also test results report in one folder. Is this possible?
2) For now I am getting test results in console, same can I export to any folder.

Please do the needful.

Thanks and Regards,
Anitha

RE: How to build ,compile and run eclipse Cute tests thru command prompt commands - Added by Thomas Corbat over 4 years ago

Well my reply was not a definitive "yes it will work with IAR". As long as the compiler supports standard C++ it won't be a problem. We don't have any license or hardware for testing such configurations. You just need to test it in your environment.

1) CUTE is just like any other C++ code from header files. Subsequently, any Gcov results are not directly CUTE related. The CUTE plug-in is just capable of visualizing the results. Please refer to the manuals of Gcov for configuring its output.
2) Sure, you can redirect the console like you could from any other program using a pipe or put it into a file directly.

Regards
Thomas

(1-15/15)