Debug a GTest in VS2010 - c++

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.

Related

Android Studio debugger doesn't work in C++ code

I don't have much prior experience in Android Studio. I'm trying to debug a problem in C++ code. Djinni and ninja are used in the product. I know that the same setup with zero additional tweaks is debuggable at another machine.
But on mine, the debugger doesn't want to stop at C++ breakpoints at all. Sometimes it shows "no executable code is associated with this line" message. Other times the breakpoints are just plain red without a check mark.
Debugger log says the debugger is attached.
I don't see the "app/.cxx/Debug" folder, only the "Release" one (the other machine also has only "Release"). Build.ninja files contain release flags for cpp code. Via the search in all files in the project directory, I did not find the set of debug flags that are used in CMakeLists anywhere among the build artefacts.
It seems like I tried everything that I found on SO:
checked for correct build variants
checked jni debuggable true, minify enabled false, empty proguard file
tried different debug types in Run/Debug config -> Debugger (however idk which symbol directories to add manually)
tried debugging in an emulator as well as on a real device
in the emulator, uninstalled the app and did cold boot
used the same Studio version as on that other machine
used the latest Studio version, and the newest preview
cleared caches, cleaned, refreshed linked C++ projects
made clean Studio reinstall with prior deep cleaning of all Gradle and Android files via Terminal
upgraded Gradle
use the same NDK version as in build.gradle
added NDK dir to local.properties manually
tried using "make module app" instead of simple "make" command
Nothing helped so far. Only once after a crash the execution stopped and showed an assembly line with a simple call stack, without details.

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.

Unit Testing Windows 8 WIndows Runtime Component With TeamCity

I'm not a Windows 8 developer so excuse any stupid questions.
I have a Windows 8.1 application built in Visual Studio 2013 via a .sln file. This contains a number of projects: there is an application that relies on a library, this library (call it datalib) is built as a Windows Runtime Component (not a DLL);
there is also a test project which runs tests on 'datalib'
All of this works fine in VS2013, i.e. the tests execute.
I've been tasked with creating a TeamCity build for this so I've create a TeamCity build that builds against the sln file but I can't get the tests to execute (they're MSTest tests).
In my configuration I've added the test.dll (in the 'include assembly files list') but when I add this on it's own then I get a bunch of errors around references to types in the 'datalib'
The 'datalib' is built into datalib.winmd (I'm assuming this is the binary) so I thought that including this in the assembly list would fix my problem, but it doesn't.
I assume I'm missing something simple, what is it?
I'm now able to do this and it was a multi step process.
Firstly you don't load/test the winmd file directly you have to load the appx that's created by the test project 1; you can't use the MSTest runner that comes with TeamCity, instead you have to install the Visual Studio Test Runner plugin [2]; you have to run the build agent in an interactive process; and finally you have to install the root certificate that the application was signed with.
You reference the appx like you would a DLL
To install the build agent and have it run interactively it wasn't good enough to use the service and mark 'Interact with Desktop' you need to have full interaction so the agent has to be run from the desktop, as admin, at startup. To do this I had to create a scheduled task that run at startup and was given full privileges.
I installed the cert by running the ps1 file in the same directory as the appx file (Add-AppDevPackage.ps1) I'm sure this is overkill but it seemed like the easiest option at the time
[1] http://msdn.microsoft.com/en-us/library/hh691189.aspx
[2] https://confluence.jetbrains.com/display/TW/VSTest.Console+Runner

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.

unit test in eclipse g++

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.