Answered Specified cast is not valid and the Ignore attribute

  • Tuesday, July 08, 2008 4:30 PM
     
     
    If I have any tests attributed with [Ignore], when I run the tests from the command line with only the /testmetadata switch, I get the error "specified cast is not valid".  No tests are executed.  Here is my command line:

        mstest /testmetadata:.\Core\Core.vsmdi /detail:errormessage

    If I specify the /testlist, or just run with the /testcontainer, then the tests execute as expected.  It is only if I have ignored tests in the vsmdi that the run failure occurs.

    Is this a bug with VS2008, or expected behavior?

    Thanks!


    This post is similar to the following post, but with a bit more specific information (the Ignore attribute):

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=226537&SiteID=1

Answers

  • Wednesday, July 23, 2008 3:56 PM
     
     Answered
    Unfortunately, I cannot share the project with you.   I'll keep trying to recreate this with a smaller project.  When I am successful, I'll post here and send you an email.

    Thanks!

All Replies

  • Thursday, July 10, 2008 8:43 PM
     
     

    Hello,

     

    I tried reproing the problem with a newly created solution and two simple tests in a test list (one of which has the Ignore attribute), but the scenario you mentioned does not happen. Please let us know if you can re-create your scenario from within scratch (new solution).

     

    Do you see the problem if you specify a particular testlist with the /testlist attribute?

     

    Thanks,

    David Gorena Elizondo

    [MSFT] VSTT

     

  • Tuesday, July 15, 2008 12:07 AM
     
     
    Thank you for looking into this.  Unfortunately, I wasn't able to recreate the problem from scratch.  I'm working on getting this to occur with a project simpler than the Core project that it occured in initially.  In the Core project, I can get it to occur repeatedly, just by uncommenting the Ignore attribute on any test.

    So, I tried to set up the logging.  I changed my VSTest.exe.config file to:

    <?xml version ="1.0"?>
    <configuration>
        <runtime>
            <assemblyBinding xmlns="urnTongue Tiedchemas-microsoft-com:asm.v1">
                <probing privatePath="PrivateAssemblies;PublicAssemblies"/>
            </assemblyBinding>
        </runtime>
    </configuration>
    <system.diagnostics>
        <trace autoflush="true" indentsize="4">
            <listeners>
               <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\VSTestHost.log" />
            </listeners>
        </trace>
        <switches>
            <!-- You must use integral values for "value".  Use 0 for off, 1 for
                 error, 2 for warn, 3 for info, and 4 for verbose. -->
            <add name="EqtTraceLevel" value="4" />
        </switches>
    </system.diagnostics>

    The test run still doesn't happen, and no VSTestHost.log file is created.  The command line prints:

    C:\QATest\vs2008\vstest\na\Core>mstest /testmetadata:.\Core.vsmdi
    Microsoft (R) Test Execution Command Line Tool Version 9.0.21022.8
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading .\Core.vsmdi...
    UTA050: Test VRP_Validation_Tests.FieldValidation_Tests.VRP_Routes_EndDepotName_
    IsValid has the Ignore attribute. Ignoring test.
    Starting execution...
    Specified cast is not valid.


    What do you suggest I try next?

    Thanks!
  • Friday, July 18, 2008 11:23 PM
     
     

    Would it be possible to share your project with us? If so, can you please send it to dgorenae@yahoo.com?

     

    Thanks,

    David Gorena Elizondo

    [MSFT] VSTT

     

  • Wednesday, July 23, 2008 3:56 PM
     
     Answered
    Unfortunately, I cannot share the project with you.   I'll keep trying to recreate this with a smaller project.  When I am successful, I'll post here and send you an email.

    Thanks!
  • Wednesday, September 09, 2009 10:38 PM
     
     
    Do you see the problem if you specify a particular testlist with the /testlist attribute?
    I also experienced this problem when I added Ignored tests to my test project.  And it doesn't happen when I specify the /testlist to the mstest command.  But that isn't a solution for me, because lots of developers will be adding unit tests, and they can't all be expected to remember to add their tests to the global testlist.

    This problem is pretty easy to reproduce for me.  Just ignore about 10 tests and it starts happening.  This bug really has to be fixed.
  • Thursday, October 29, 2009 7:13 PM
     
     
    It looks like the issue could be empty test lists combined with the Ignore attribute:

    http://social.msdn.microsoft.com/forums/en-US/vstsprofiler/thread/e466550e-475f-4c0f-8225-26147cc3918c/