BoundfoxStudios / fluentassertions-unity

FluentAssertions for Unity
Apache License 2.0
54 stars 6 forks source link

System.MissingMethodException with Rider's Standalone launcher #8

Closed MerlinM1S closed 1 year ago

MerlinM1S commented 1 year ago

The package works perfectly fine while running a test inside of Unity.

However, if i try to run the following example "2".Should().BeEquivalentTo("1"); with Rider's Standalone Nunit Launcher, i get the following exception

System.MissingMethodException : Method not found: 'Boolean System.String.Contains(System.String, System.StringComparison)'. at FluentAssertions.Primitives.StringValidator.IsLongOrMultiline(String value) at FluentAssertions.Primitives.StringValidator.Validate() in .\Library\PackageCache\com.boundfoxstudios.fluentassertions@ac405b32a6\Runtime\FluentAssertions\Primitives\StringValidator.cs:line 37 at FluentAssertions.Primitives.StringAssertions'1.BeEquivalentTo(String expected, String because, Object[] becauseArgs) in .\Library\PackageCache\com.boundfoxstudios.fluentassertions@ac405b32a6\Runtime\FluentAssertions\Primitives\StringAssertions.cs:line 116 at ...

Is there any chance to get this to work? (It's useful for faster testing and profiling)

Thanks Markus

ManuelRauber commented 1 year ago

Hi!

I've never used the testing outside of Unity.

Can you either give me a minimal example in a zip file to test or at least more information for the setup needed to run the tests outside of Unity?

Thanks!

MerlinM1S commented 1 year ago

Thank you for the fast answer!

I'm talking about this feature of the IDE Rider: image

Sadly, if you are not using Rider, you probably won't be able to replicate the issue.

ManuelRauber commented 1 year ago

Thank you for the fast answer!

I'm talking about this feature of the IDE Rider:

image

Sadly, if you are not using Rider, you probably won't be able to replicate the issue.

I do use Rider. :)

I will take a look if that is possible what you're trying to achieve.

ManuelRauber commented 1 year ago

@MerlinM1S

I've just tested it by creating two test assemblies. One for edit mode and one for play mode.

I put in the test code from your first message and switched to Standalone NUnit Launcher:

image

So far, it works on my machine®, and I get the expected output.

Can you tell me more about the environment?

I've tested:

ManuelRauber commented 1 year ago

Oh, one more thing: Did you choose the correct mono executable in File -> Settings -> Build -> Toolset. There you need to use the same mono executable as you do in Unity.

MerlinM1S commented 1 year ago

Thank you for testing. It's great to know that it can work in theory!

I have the exact same specs (Unity Version, Rider Version and Rider Plugin Version). The only difference is that I am using Windows. I hope that this does not make a difference.

I changed the "API compatibility level*" of the default project to ".NET Framework".

If I leave it as ".NET Standard 2.1", i get the following strange exception

System.BadImageFormatException : Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
  ----> System.BadImageFormatException : Cannot load a reference assembly for execution.
   at Tests.NewTestScript.BasicTest()
--BadImageFormatException

Previously, "Mono executable path" was not set. I changed it to image , but I get the same results.

ManuelRauber commented 1 year ago

I only test against .NET Standard 2.1.

I've found an issue at JetBrains' Issue Tracker: https://youtrack.jetbrains.com/issue/RIDER-73925

The issue is directly for Windows machines, it looks like the error is only present there. Unfortunately, I do not have access to a Windows machine, since I'm using macOS. By any chance, do you have access to a macOS or a Linux machine and test it there?

Otherwise I'm not sure, if I can help out here, but if you'd find a fix, I'd be happy to help get it into the lib!

MerlinM1S commented 1 year ago

Thanks for your help. It seems like the issue is really related to Rider on Windows.