YoloDev / YoloDev.Expecto.TestSdk

27 stars 16 forks source link

Test failures due to C# code generation. #108

Open sheridanchris opened 1 year ago

sheridanchris commented 1 year ago

While using this sdk in conjunction with Marten. Marten's C# code generation causes exceptions and failing tests. I have absolutely no idea what the issue could be or if a fix is possible. I can create a repro if needed.

Failed API Tests.storeMany/delete/saveChanges [1 s]
  Error Message:
   Exception has been thrown by the target of an invocation.
  Stack Trace:
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Marten.Internal.CodeGeneration.DocumentProviderBuilder.BuildProvider[T]()
   at Marten.Internal.ProviderGraph.StorageFor[T]()
   at Marten.Internal.Sessions.QuerySession.StorageFor[T]()
   at Marten.Internal.Sessions.DocumentSessionBase.store[T](IEnumerable`1 entities)
   at Marten.Internal.Sessions.DocumentSessionBase.Store[T](T[] entities)
   at Marten.Session.storeSingle[a](a entity, IDocumentSession session) in /home/christian/Programming/Marten.FSharp/src/Marten.FSharp/Marten.FSharp.fs:line 898
   at Tests.CRUDTests@508-14.Invoke(Tuple`2 tupledArg) in /home/christian/Programming/Marten.FSharp/tests/Marten.FSharp.Tests/Tests.fs:line 513
   at Tests.Pipe #1 input at line 151@151-2.Invoke(a x)
   at Tests.withDatabaseAndStore@129-2.Invoke(DocumentStore _arg1) in /home/christian/Programming/Marten.FSharp/tests/Marten.FSharp.Tests/Tests.fs:line 129
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 508
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 453
   at Microsoft.FSharp.Control.AsyncPrimitives.RunImmediate[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1153
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1159
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1504
   at Tests.testFixture'@151-1.Invoke(Unit unitVar0) in /home/christian/Programming/Marten.FSharp/tests/Marten.FSharp.Tests/Tests.fs:line 151
   at Expecto.Impl.execTestAsync@569-1.Invoke(Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 508
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
Alxandr commented 1 year ago

There's not very much to go off here. Are you sure the error is even related to the test SDK? Does it work if you run expecto from main directly?

sheridanchris commented 1 year ago

It does work when I run the tests using dotnet run. The issue only occurs when using the test SDK.