adamchester / expecto-adapter

Visual Studio test adapter for Expecto (https://github.com/haf/expecto)
MIT License
28 stars 16 forks source link

Parameter count mismatch in Discovery #29

Open jackfoxy opened 7 years ago

jackfoxy commented 7 years ago

To reproduce, use my project https://github.com/jackfoxy/PSlogger

Checkout initial commit in master branch. (I will be making more commits, and the initial commit is quite simple, with only one test in one test list.)

Attempting test discovery results in:

[8/24/2017 12:35:06 PM Informational] ------ Discover test started ------
[8/24/2017 12:35:07 PM Error] System.Reflection.TargetParameterCountException: Parameter count mismatch.
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Expecto.Impl.getTestFromMemberInfo@1138-1.Invoke(a focusedState)
   at Microsoft.FSharp.Core.OptionModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpOption`1 option)
   at Expecto.Impl.testFromMember(MemberInfo mi)
   at Expecto.Impl.testFromType@1172-1.Invoke(MemberInfo mi)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@165.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at Expecto.Impl.testFromType@1167.Invoke(Type t)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@165.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at Expecto.Impl.testFromAssemblyWithFilter(FSharpFunc`2 typeFilter, Assembly a)
   at Expecto.Impl.testFromAssembly@1268-1.Invoke(Assembly a)
   at Discovery.DiscoverProxy.DiscoverTests(String source)
   at Discovery.DiscoverProxy.DiscoverTests(String source)
   at Discovery.Discoverer.Microsoft-VisualStudio-TestPlatform-ObjectModel-Adapter-ITestDiscoverer-DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
[8/24/2017 12:35:07 PM Informational] ========== Discover test finished: 0 found (0:00:00.7190687) ==========
alex-bogomaz commented 7 years ago

@jackfoxy - in this file https://github.com/jackfoxy/PSlogger/blob/master/tests/PSlogger.Tests/Tests.fs you actually have parametrized test list:

[<Tests>]
let testSimpleTests azureConnectionString =
    testList "write and read log record" [
        testCase "equality no optional" <| fun () ->
            let testDate = DateTime.UtcNow.AddDays(-7.)
            let inLog = {log1 with 

Not sure how it is possible to handle such tests in "Test Explorer" window. Should adapter skip such test lists?

jackfoxy commented 7 years ago

Perfect! Thanks, @alex-bogomaz Closing this issue @MNie

jackfoxy commented 7 years ago

@alex-bogomaz @MNie I closed this prematurely.

A better behavior would be to trap this exception, write a message that parameterized lists cannot be handled by the adapter, and continue to process the non-parameterized lists.