locked
Adding a class to my test project will cause Pex to fail - even though it is not referenced.

    Question

  • Hi,

      I've got a pretty decent sized test project that has probably about a total of 200 Pex generated tests. I often do right-click->Pex Explorations. However, recently, it suddenly started reporting "could not find any tests to run." Actually - it did this for everything, including PexMethods that had previously been working.

      I finally traced it to the following object. Note that the object doesn't have to be referenced in the test project. Just its existance is enough to cause Pex to fail. If I delete it (and make no other chnages) then pex explorations start working again. Here is the code:

     public class MyGeneraicVar : IVariableSaver
    
     {
    
      public bool CanHandle(IVariable iVariable)
    
      {
    
       return true;
    
      }
    
    
    
      public IEnumerable<string> SaveToFile(IVariable iVariable)
    
      {
    
       yield return "save;";
    
      }
    
    
    
      public IEnumerable<string> IncludeFiles(IVariable iVariable)
    
      {
    
       yield return "file.h";
    
      }
    
    
    
      public T LoadResult<T>(IVariable iVariable, ROOTNET.Interface.NTObject obj)
    
      {
    
       return default(T);
    
      }
    
     }
    
    

    Looking at this, the only thing that I can guess might be causing this is the ROOTNET.Interface.NTObject - which points into a C++/CLI C++ wrapper library. However, in my tests I'm not using or accessing any real C++ types that are under Pex method control. Aldo, that NTObject is an interface, not a real object (Pex already gives me errors when it tries to load the C++/CLI assemblies, but I've always ignored those errors so far).

    What is causing this? The error message isn't helpful in this case. Is there some way I can work around this?


    Gordon
    Tuesday, January 25, 2011 6:28 AM

Answers

  • Hi,

      Ok - I got done with all the fun stuff in my project (that is, new features) and now it is time to go back and clean everything up. I managed to solve this by creating a new platform in my project (x86), and set all the .NET projects from Any CPU to x86. After that, it seems like Pex started working again.

      Cheers,

        Gordon.


    Gordon
    • Marked as answer by GordonTWatts Thursday, April 14, 2011 2:59 PM
    Thursday, April 14, 2011 2:59 PM

All replies

  • Hi,

      Here is a dump of the error log from Pex output:

    launching pex
    starting...
    C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\LINQToTTreeLib.Tests.dll
    "C:\Program Files\Microsoft Pex\bin\Microsoft.Pex.exe" C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\LINQToTTreeLib.Tests.dll /x64failsilently /clrversion:v4.0.30319 /referencedprojectassemblies:LinqToTTreeInterfacesLib;LINQToTTreeLib;TTreeDataModel;TTreeParserCPP.Tests;TTreeParser /donotopenreport /reportlevel:Xml /reportrootpath:C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\reports /testframework:VisualStudioUnitTest /testlanguage:cs /testprojectfile:C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\LINQToTTreeLib.Tests.csproj /testprojectnotupdate /testprojectskip
    launching new pex process
    "C:\Program Files\Microsoft Pex\bin\Microsoft.Pex.exe" C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\LINQToTTreeLib.Tests.dll /x64failsilently /clrversion:v4.0.30319 /referencedprojectassemblies:LinqToTTreeInterfacesLib;LINQToTTreeLib;TTreeDataModel;TTreeParserCPP.Tests;TTreeParser /donotopenreport /reportlevel:Xml /reportrootpath:C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\reports /testframework:VisualStudioUnitTest /testlanguage:cs /testprojectfile:C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\LINQToTTreeLib.Tests.csproj /testprojectnotupdate /testprojectskip
    starting monitored process
    listening to monitored process (cold start)
    launched Pex 0.94.51023.0 x64/IA64 Edition on .NET v4.0.30319
    00:00:00.0> starting execution
     00:00:00.1> reflecting tests
      !warning! [reflection] System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at module LINQToTTreeLib.Tests.dll
      !warning! [reflection] System.BadImageFormatException: Could not load file or assembly 'libCoreWrapper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. at module LINQToTTreeLib.Tests.dll
      !warning! [reflection] System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\libCoreWrapper.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. at module LINQToTTreeLib.Tests.dll
      !warning! [reflection] System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\gwatts\Documents\ATLAS\Projects\LINQToROOT\LINQToTTree\LINQToTTreeLib.Tests\bin\Debug\libCoreWrapper.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. at module LINQToTTreeLib.Tests.dll
      !warning! [metadata] no explorations found after applying all filters; did you forget a [PexClass] or [PexMethod] attribute?
    
    00:00:01.2> [finished] execution time 00:00:01.1730671.
    	-- 0 critical errors, 0 errors, 5 warnings.
    	-- 0 generated tests, 0 failing, 0 new, 0 inconclusive.
    
    [coverage] skipping coverage reports...
    [reports] skipping html reports
    
     EXPLORATION FAILED
    
    
    monitored process exited with could not find any test to run (-1013 - 0xfffffc0b)
    finished
    

    What does that incorrect format error mean? Does it have to do with the fact that the C++/CLI is Win32 built, and my libraries and Test projects are "Any CPU"?

    Many thanks!


    Gordon
    Sunday, February 27, 2011 11:26 PM
  • Hi,

      Ok - I got done with all the fun stuff in my project (that is, new features) and now it is time to go back and clean everything up. I managed to solve this by creating a new platform in my project (x86), and set all the .NET projects from Any CPU to x86. After that, it seems like Pex started working again.

      Cheers,

        Gordon.


    Gordon
    • Marked as answer by GordonTWatts Thursday, April 14, 2011 2:59 PM
    Thursday, April 14, 2011 2:59 PM