Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException during test discover process #63

Closed
gomons opened this issue Jul 12, 2016 · 5 comments
Closed

NullReferenceException during test discover process #63

gomons opened this issue Jul 12, 2016 · 5 comments
Labels

Comments

@gomons
Copy link

gomons commented Jul 12, 2016

When I build my test project:

ERROR: Exception while resolving test locations and traits in C:\Siarhei.Homan\Win32\Debug\opencv_core310d.dll
System.NullReferenceException: Object reference not set to an instance of an object.
   at GoogleTestAdapter.DiaResolver.DiaResolver.GetFunctions(String symbolFilterString)
   at GoogleTestAdapter.TestCases.TestCaseResolver.FindTestCaseLocationsInBinary(String binary, List`1 testMethodSignatures, String symbolFilterString, String pathExtension)
@csoltenborn
Copy link
Owner

Hi Sergey,

thanks for the report! Here are a couple of questions for the sake of narrowing down the cause:

  • Are you using traits with your tests? If this is the case: Are you using the latest traits macros file (released with version 0.7.0) or the previous one?
  • Which VS version (edition, version, and update level) are you using?
  • I assume GTA is working as expected, but you only have some tests without test locations (i.e., the test explorer does not provide links to the source location of the according tests) or traits? Only the tests contained in opencv_core310d.dll (if any) should be affected...
  • Is there any chance that you can share the solution causing that problem, such that we can reproduce it over here?

@gomons
Copy link
Author

gomons commented Jul 13, 2016

Hi Christian!

  1. I don't use traits (I believe I don't because I don't know how to use them)
  2. I use Visual Studio 2015 Community Edition with v120_xp toolset
  3. If I use opencv dll in my test application, GTA can't discover any tests. But if I remove opencv code from test - all tests discovered as expected.
  4. I attached solution example. In the example solution there is no NullReferenceException, but the problem remains - tests are not discovered and I can't use GTA. If you comment out opencv usage (lines 2 and 6 in BindTest/main.cpp), tests are discovered.

GoogleTestAdapter.zip

@csoltenborn
Copy link
Owner

Hi Sergey,

thanks for the example solution! I have built that solution (although using v140_xp as toolset) and might have found the cause for your problems: Please run the test executable from the command line (which is always a good idea in case GTA has issues - see our trouble shooting section ;-) ). You will probably get windows dialogs complaining about missing dlls (in my case, openvc_core310d.dll and opencv_imgcodecs310d.dll), and if I comment out the lines you suggested, the test executable runs fine. You should be able to fix that by adding those dlls to the path (either system wide or using our Path extension option, see trouble shooting section).

However, this does not explain why our code produces a NullReferenceException, and to be honest, I don't see how this could happen when looking at the code mentioned in the exception. Would you be willing to help debug this issue, even if the above solves your concrete problem?

@gomons
Copy link
Author

gomons commented Jul 14, 2016

Thank you alot, Christian!

I'm sorry for my inattention... It's all because of my environment settings, I can run executable from Visual Studio because I use Envirement option and I just forgot about it.

I reproduced NullReferenceException. I attached modified solution. The NullReferenceException reason: not all dll dependencies satisfied. So I just added opencv_core310d.dll to build output directory. If I put other dll that needed to start application all is ok.

GoogleTestAdapter.zip

@csoltenborn
Copy link
Owner

Hi Sergey,

no problem :-) I will try reproduce the NRE with your new solution soon...

csoltenborn added a commit that referenced this issue Jul 19, 2016
… efforts are taken to parse SourceFileLocations (#63)
csoltenborn pushed a commit that referenced this issue Oct 21, 2017
* fix path for loc files

* fix path to lcl files

* mark vsix proj at not component

* add common dynamic projects to setversion

* fix path

* remove unnecessary swix res and add option to set isproductcomonent for setup

* check if property is set to true in microbuild before setting it

* rename microbuild variable for clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants