unit test in eclipse g++ - c++

I am using Eclipse to develop some projects and implement unit test by using google test. everything was fine this morning. I can build project and run unit tests. however, after i commit the local changes and then pull the codes from repository using git tortoise, the unit tests stopped working any more. I still can build the project.
I got msg:
Unknown error during parsing Google Test module output: unexpected test module output
this is the msg in the console window:
The target endianness is set automatically (currently little endian)
[New Thread 4496.0x520]
and the project would stop running before we even step into the main function in the unit test. Since, the compiler gave me so little info, i wonder if any one here might have a clue.

I ran into the error msg "...:unexpected test module output" when I added a main function and DID NOT exclude it from test build (and apparently g++ linker did not complain about same symbol error, you should be able to see it from the build msg for test build).
I excluded my app main from test build (right click on your app main, go to Resources Configuration, then Exclude from Build..., and finally check your test build and click OK), the test ran without any problem.

It can be a little irrelevant already, but I had the same problem, then I noticed wrong C++ Aplication value for my GoogleTest Configuration, changed it and now everything is fine.
I had the option for Debug config there. (Run -> Run Configurations... -> C/C++ Aplication). Eclipse changed it itself somehow.

Related

Is there a way to get the information from MS unit test framework outside of the VS environment?

I created a test framework to test a sample application. This basically required creating a Solution for my sample application and then adding a Native Test Project, which can test the application.
The test project generates an .exe, but if I were to execute the .exe on it's own, it does nothing.
Is there a way to get information from the test programme so it can be used for other purposes outside of the VS environment?
Yes, you can run unit tests without VS2013.
Use Run automated tests from the command line using MSTest source to do so.
In general it says:
Open a Visual Studio command prompt.
Either change directory to your solution folder or, when you run the MSTest.exe program in step 3, specify a full or relative path to the metadata file or to the test container.
Run the MSTest.exe program.
I hope it will solve your issue.
It took a couple of days, but I've found that DeJaVo's answer is incorrect. Because I am running a Native Test Project, MSTest will not work with it. To run a Native Test from the command line, use VSTest.Console.

How to run C++ test on visual studio online

I have test cases that are executable (*.exe files). There is no user interface involved.
How do I use Team center /visual studio online to run these test cases on server.
For now, either on demand running or scheduled running will work for me.
(Currently I have no test case that runs on server. So you may mention the basic setup. )
I have written some test cases (they are exe files). I can run them locally line any other exe file.
My code is in C++.
My test cases are in C++.
You could run them as part of your build. Just configure a build in VSO for your solution, and then modify the msbuild project file to call your tests and send the output to the build folder so it gets uploaded as part of the drop. If you are using VS, you would get a better experience using the VS unit testing support (i.e., get results in VS): http://www.visualstudio.com/get-started/run-tests-with-builds-vs.

Debug a GTest in VS2010

I have a solution in VS2010 (C++ code) that includes test files directly in the src and include folders for the project of a plug-in. I am using Google Test framework. The plug-in, let's call it myPlugin, is running on a software, say mySoft.
######################################################################
Here is the issue:
I can run tests with command line, ok.
But i would like to debug inside the GTESTs. Why ? Because the tests are not really unit tests, they are setting a lot of parameters, and i would like to check step by step that everything is set ok. I know this is not mandatory to solve this and that i can debug the application itself. Anyway, this is my question, i want to debug inside a gtest.
I try to config VS2010 properties so as to launch the tests from VS, and this is not working.
############################################################################
More details:
To run the tests, i have to have an executable launched. In other words, i am running tests while an application, mySoft.exe, is running. The plug-in is running using another executable, the sdk_mySoft.exe.
The command lines (that work) are
mySoft.exe -sdkRun=pluginLevel ;pluginDirName;version;myPlugin_x64.dll
--gtest_output=xml
-sdkRun is in-house command offered by the sdk to set up GTests. So here i launch my application, run the plug-in, get some logs from google test, ok.
Then, I try to configure VS with these debugging properties:
Command $(SolutionDir)\bin64\mySoft.exe
Command Arguments -sdkRun=pluginLevel ;pluginDirName;version;myPlugin_x64.dll
--gtest_output=xml
and here this is not working.
Error is
Debugging information for 'mysoft.exe' cannot be found or does not
match. Cannot find or open the pdb files.
Any idea ?
How to debug in gtest, taking into account the special conditions here: have to launch an application?
Thanks
To debug the GTest, the debugger needs to be linked to application.
Launching the application, click on CTRL gives access to the VS debugger.

Running Go tests in Eclipse

I have eclipse and goclipse installed, all is well, I can run a console app in the IDE. It is possible to execute the unit tests in the IDE too?
The latest release of goclipse (0.7.6) does provide a means of doing testing using the "testing" package assuming you have followed the project structure recommended in C:/Go/doc/code.html in the installed file structure created when installing Go.
Using the Eclipse "run external tools" button create a new external tool configuration as follows:
on the Main tab the location is C:/Go/bin/go.exe
the argument is test
the working directory should point to the eclipse workspace folder containing the package that is to be tested (eg ${workspace_loc:/goProject/src/pnp}, where pnp is the name of the package NOT the name of the go file that contains the test).
You can now run the test by pressing the Run button in the usual manner, having given the configuration a sensible name eg: go test pnp. You can now add further tests to the package in different go files (or the same one) and all the tests will be carried out in a manner that is expected.
Yes it is if you make a makefile to do so... If you are asking if goclipse has a built in testing facility like JUnit for java the answer is no though.
The issue 5 was asking to "Integrate 'go test' into the IDE and developer workflow."
It now has just been closed (August 2015), with commit 9c3c858 (next release after 0.11.2), with the following documentation:
Each Go project has 3 built-in Build Targets, which are ways in how the project can be built.
These can be viewed and configured in the Project Explorer:
The modes are:
./... #build: The default build. Builds all Go packages present in the project (excluding test packages).
./... #build-tests: Builds all Go test packages present in the project.
./... #[run-tests]: Builds all and runs Go tests.
Each target can be enabled or disabled when for Eclipse project builds. (There is not much point to have both #build-tests and #[run-tests] enabled though.)

OCUnit: How to run tests without launching iPhone simulator?

I'm following iOS Development Guide: Unit Testing Applications. However, when I attempt to build (Command+B) the LogicTests target (step 8 of "Setting Up Logic Testing"), I get the error: "The selected run destination is not valid for this action."
Since I added my application target to LogicTests's target dependencies, I'm able to run the unit tests with Command+U, but this also launches the iPhone Simulator.
To save time & resources, is it possible to run the OCUnit tests (both logic & application tests) without launching the iPhone Simulator?
I understand the annoyance of the simulator popping up in unit tests. The best remedy I've been able to find is to do Command + U, followed by Command + H when launching unit tests. (Control + H hides the simulator after it appears.) Since it appears nearly instantaneously, this can be an effective way of getting it out of your range of vision.
I've managed to run my unit tests which test my model classes without the simulator being launched as follows:
I didn't set any bundle loader or test host build settings, instead I just added the .m files I was unit testing to the Build Phases Compile Sources.
I then ran the unit tests from the command line using:
xcodebuild -verbose -target TheElementsUnitTests -configuration Debug -sdk iphonesimulator5.0 clean build
Not really sure why this didn't launch the simulator, but it definitely didn't!
Here's a small AppleScript that I set to run for Generates output in Testing behaviour configuration:
#!/usr/bin/osascript
activate application "Xcode"
It brings Xcode back immediately after pressing command + U.
P.S. I also opened a bug and Apple marked it as a duplicate. So, they're aware.
How much time/resources? Rather than focusing on reducing those, I'd focus on expanding your tests to go far beyond Apple's original "Logic Test" guidelines. Those guidelines were limiting, and written before Xcode 4. Now you can write tests without thinking, "Is this a logic test or an application test?" -- just test everything.