Where to find the parsed Boost.Test output in Eclipse - c++

There is already a thread here that partially answers my question .
On Eclipse 3.7.2 I followed the approach provided there and I could successfully accomplish the steps creating and setting up a new error parser and adding it to my current project. After executing my Boost.Test (boost rel. 1.48.0) Unit Test, on the Eclipse console I get the same output as the output I get when no parsing is done (e.g. when executing the Unit Test outside Eclipse (e.g. on a Linux terminal)). I searched for a new Eclipse console where the parsed Unit Test output could be displayed (similar to the consoles by e.g. gcov, gprof or cppcheck in Eclipse) but found nothing alike.
Where should the parsed unit test output be displayed? In case the parsed output shall be displayed in the Eclipse Console view, are there any suggestions what might have gone wrong with the parsing in my case?
Thanks in advance.
P.S.: Thanks to casperOne and kleopatra for teaching me manners.

If you're using Eclipse there is also a really nice plugin called TestRunner for running CDT unit tests much like Java or Python unit tests. It handles the unit-testing parsing for you. You'll get a separate console window for your unit tests and it arranges them with level filters. Clicking on an error/warning takes you to the unit-test line number in your editor. You also can set the verbosity level as well as a few other settings from inside Eclipse.
You can directly install the plugin by using the following link in Eclipse updates https://raw.github.com/xgsa/cdt-tests-runner/tests_runner_demo/testsrunner/org.eclipse.cdt.testsrunner-updatesite/site.xml

In order to eclipse parse errors, the error must be print in the console view at compile time. If you are emitting errors in runtime, you must add your program to be called by the Makefile.
That's how I do in embedded systems.

Related

Qt Creator seems to be struggling to parse Valgrind memcheck output with googletest

When I run Valgrind memcheck tool from Qt Creator on my unit test project (which is using google test), I have a weird issue with the output. Qt Creator is convenient as it filters out the external errors but with my unit test project it looks like it struggles to parse the valgrind ouput. As an example, at some point in one of my tests I have the following:
QRegularExpression regExp(RegExpGetter::date());
ASSERT_TRUE(regExp.isValid());
EXPECT_FALSE(regExp.match(QStringLiteral("29-02-2021")).hasMatch());
//...
And while some Valgrind output is parsed correctly by Qt Creator, others (such as the output produced by my test above, but also many other tests) are displayed in the console output formatted as xml. Now, I noticed that as soon as this issue arises, the next errors are not parsed correctly but are all displayed in the console (which makes it hard -- and that's an understatement, to detect my own errors). I created some explicit memory leaks and while some in the previously ran test suites are displayed correctly, others are not but I can still find them in the console if I search for them. Here's a screenshot of the issue.
I tried disabling Google Test ouput, thinking it may conflict with how Qt Creator parses the valgrind results, but it didn't help. Any idea how to solve my problem?
I am running valgrind 3.16.1 and Qt Creator 4.14.2 on an Ubuntu virtual machine.

Boost testrunner in Eclipse fails to generate valid XML

I am attempting to run unit tests from Eclipse on C++ code. My Eclipse is Mars.2 Release (4.5.2). I originally downloaded the Java Developer's version, but I've installed C/C++ plugins. I wrote a simple class and then a boost unit test for that class. I can compile the code both in Eclipse and on the command line to get an executable. If I run the executable on the command line, I get this output
Running 1 test case...
*** No errors detected
So far so good.
Now if I try to run inside Eclipse, I get an error. At first it appeared that my test was not running at all. In the "C/C++ Unit" tab, I got a red bar on the right side of the screen, no information where I should be seeing individual test results, and a message "XML parse error: Premature end of file" in small text right below the row of tabs. By stopping in the debugger, I was able to see that I'm victim of a known bug. Basically there's some incompatibility between Eclipse and boost testrunner, where one is specifying XML and the other xml (different case) for the format. I tried this work-around mentioned in the discussion about the bug at that link:
As a workaround you can add following arguments in the unittests' run configuration:
--output_format=XML --log_level=all --report_level=no --
Eclipse's test runner appends it's arguments to these. Arguments after -- are passed on to your test script and ignored by Boost.Test.
With that in place, I still have problems, but the problem is different depending on whether I run with debugging or not. Without debugging, the result is the same as noted above. With debugging, I get information about my test - noting that it ran and passed - on the left side of the "C/C++ Unit" tab but I still get the red bar indicating a failure. The small text in this case says: "XML parse error: Content is not allowed in tailing section."
The bug noted above appears to be about 2 yrs old, although the discussion has activity as recently as last month. I guess there's some other work around? It seems likely that the community has been running tests in the intervening two years!
I tried updating Eclipse via Help -> Check for Updates. That did not improve my situation. I suspect that other information may be valuable to help, but I'm not sure what to provide. I'll watch comments and update if / where I can.
Reluctantly, I upgraded to the Neon.2 release of Eclipse. The underlying bug is still present, as described in my question, but the work-around noted works in that release. Copying that down from the question for completeness:
As a workaround you can add following arguments in the unittests' run configuration:
--output_format=XML --log_level=all --report_level=no --
Eclipse's test runner appends it's arguments to these. Arguments after -- are passed on to your test script and ignored by Boost.Test.
Would have been nice if this worked in Mars as well since upgrading is a bit of a hassle - especially with support for multiple development languages - but at least I can move on. Probably would have had to upgrade at some point in any case.

Xcode and Code Coverage

My application was initially not written for the Mac platform, so it has it's own unit-test system which can be triggered by a command-line. Is it possible to make use of the code coverage support in Xcode by just executing it?
I tried to make it run as a UnitTest which triggers the 'main(...)' function of my application manually (see code block), but since this process is started by the application 'xctest' a lot of things are missing like resources from my application bundle, etc (incorrect or wrong paths, ...).
- (void)testExample {
int main(int argc, char* argv[]);
main(...);
}
Is there any way just to tell Xcode that my application should be started so it can output the code coverage that can be reviewed inside Xcode?
I didn't use XCode coverage tools but I used gcov before. Anyway in this article there is information how to create llvm coverage report. So you can use your unit-test system with llvm's coverage flags and then create .profdata report with llvm-profdata tool.
As I understand Xcode's code coverage tool also creating .profdata report and uses it. I have no straightforward solution but you may find something with this information. If you find a way to make Xcode uses your .profdata it's done :)

unit testing a bison generated parser

I have eclipse with cdt and a project which contains files generated by flex and bison, the project runs perfectly but I couldn't run it as a unit test, here the things I tried:
CUTE
As the answer on this question says, I couldn't find a way to test a project that already exists, so this didn't work.
CppUnit is old as the answer said(didn't try it though but I don't want an old thing).
CDT unit testing
As this question states, unit testing is now a part of cdt, I installed it and installed googletest and followed the instructions but when I run it, it says : Unknown error during parsing Google Test module output : Unexpected test module output.
This is another question getting the same message but it doesn't have an answer(except in comments which is the same answer I followed when setting up cdt unit testing).
and after I ran this test, I got compiler errors in yacc.cpp and lex.yy.cc which I didn't get when running the project in normal.
Goal
I'm a university student doing a project with four collegues, we're building a compiler to a language specified by the professors.
I have seen a question on "bison flex unit testing", this is it : Unit test of flex bison scanner parse, how to drive the test case
but the poster of the question is using C, we're restricted to use C++ in both scanner and parser, so the question can't really help me.
PS
because running the project without unit testing worked well, I thought the error isn't with my yacc.y or lex.l, that's why I didn't post them, if they are needed I'll edit my question.
One last thing, I'm running linux mint 17.1 64bit.

Running BOOST unit tests from Visual Studio 2010

I am just starting to work with QuantLib project. There are quite a few BOOST unit tests defined, hence the question: is there an easy way to run these tests selectively from Visual Studio (and see results)?
I've only used unit testing in .Net languages so far, and there you can either use the built-in test runner if you use MsTest, or some add-on (I used Resharper and TestDriven.NET) for other frameworks. There you can choose which tests you run, and you can run them with the debugger attached (which is unfortunately useful sometimes). Are there similar add-ons for BOOST tests in unmanaged C++?
Yes you can!
If your boost unit test project is defined correctly, then you can run the entire test project from VS10 debugger by clicking
right click on project --> Debug --> Start new instance
This will run the tests inside VS framework which will give you all the debugger goodies.
For running specific test suites/cases, just edit the project command line arguments under
right click on project --> Properties --> General --> Debugging
and add the parameters according to the links in the other answers
you can run any test case or test suite via command line. running tests by name
it even allows wildcards.
ReSharper C++ supports discovery and selective running/debugging of Boost tests (with Boost 1.59 and later).
I'm using the Boost Unit Test Adapter. It's free and has a very nice output. It can also list the time the single tests consumed and you can start single tests and group of tests.
You can download it here:
https://visualstudiogallery.msdn.microsoft.com/5f4ae1bd-b769-410e-8238-fb30beda987f?SRC=VSIDE