Verify
Verify copied to clipboard
MAUI support
Is the feature request related to a problem
Trying to run tests through MAUI on device in https://github.com/getsentry/sentry-dotnet/pull/1703 - usage of Verify fails with https://github.com/VerifyTests/Verify/blob/78880d64e5469dcf6ec537ba53d51e63ed047ab7/src/Verify/Naming/Namer.cs#L130
Describe the solution
A solution would be to either:
- recognize other platforms (Android, iOS) and return the correct value
- return "Unknown" instead of throwing
Describe alternatives considered
I was thinking of using RuntimeInformation.OSDescription
and check whether it contains "android", as it does in an emulator, but it seems it's not the case on some real devices.
Another option could be using the OperatingSystem
class, but I'm not sure it's available on all the supported target frameworks
@vaind happy to make some changes to the naming. although i am not sure how Verify can be used to run tests on the device. the workflow of verify relies on the ability for the received file to be written back to the same source-controlled location as the verified file. can this be achieved when running tests on the device?
It's not about using it to run tests on device. Verify is already in use for some assertions in sentry-dotnet. The problem is that when you run the same tests on an android device, the Namer
static constructor throws because it can't determine the OS name - you can see it in the stack trace in the screenshot above, including the test name in sentry-dotnet and you can see that it doesn't do anything special.
My proposal is just that Namer doesn't throw in the static constructor when run on an unknown platdorm
An update: v17.2.0 fixed the error above
but I've found another one - Verify is trying to create directories, which causes tests to fail on Android.
for example this sentry-dotnet test: SerializationTests.Serialization(name: "string", target: "string value")
[Theory]
[MemberData(nameof(GetData))]
public async Task Serialization(string name, object target)
{
var json = target.ToJsonString(_testOutputLogger);
await Verify(json).UseParameters(name);
}
System.IO.IOException : Read-only file system : '/home/runner/work/sentry-dotnet/sentry-dotnet/test/Sentry.Tests'
at System.IO.FileSystem.CreateDirectory(String )
at System.IO.Directory.CreateDirectory(String )
at InnerVerifier..ctor(String sourceFile, VerifySettings settings, GetFileConvention fileConvention)
at VerifyXunit.Verifier.GetVerifier(VerifySettings settings, String sourceFile)
at VerifyXunit.Verifier.<>c__DisplayClass1_0.<<Verify>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at SerializationTests.Serialization(String name, Object target)
--- End of stack trace from previous location ---
@vaind want to have a go at a PR to fix this?
@vaind want to have a go at a PR to fix this?
No clue what the right approach should be... maybe Verify shouldn't even be used in this case? I'll see how the discussion in the sentry-dotnet PR go and update accordingly
closing this as not supported