Skip to content

Conversation

@grendello
Copy link
Contributor

No description provided.

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello force-pushed the dev/grendel/test-runtimes branch from 3cce48b to 3d97d97 Compare November 6, 2025 11:47
@grendello grendello marked this pull request as ready for review November 6, 2025 11:47

[Test]
public void CheckItemMetadata ([Values (true, false)] bool isRelease)
public void CheckItemMetadata ([Values (true, false)] bool isRelease, [Values] AndroidRuntime runtime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if NUnit automatically finds all the enums for you, if you do: [Values] AndroidRuntime runtime

Let's see what the test run does, but I wonder if NUnit will siliently error and skip this test?

Or if it works fine, today I learned!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you decorate a bool or an enum parameter with [Values], it will enumerate all the possible values, yep :) Very handy

IsRelease = true,
AotAssemblies = true,
IsRelease = isRelease,
AotAssemblies = aotAssemblies,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a helper method for AotAssemblies, where you pass in the AndroidRuntime? And it returns true for Mono and false for the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering doing that, yeah, but then I decided that tests should be explicit as much as possible in what they do (even if it's repetitive/verbose), they should be treated as separate entities without hidden code that does something.
I made an exception in the IgnoreUnsupportedConfiguration helper method because what it does can change in the future and it would be a real shame to have to go through all the tests and change them individually.
Another exception to this, but justified I think, is the SetRuntime method when called for NativeAOT, that's just environment setup unrelated to any particular test as such, so I think it's fine.

return false;
}

Assert.Ignore ($"NativeAOT: unsupported configuration (release == {release})");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the way NUnit works, Assert.Ignore() throws an exception that tells NUnit to skip.

So, I think you could make this method void and you don't need an if-return statement in each test.

Copy link
Contributor Author

@grendello grendello Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Assert.Ignore() throws an exception, but I wanted to make the action explicit for human readers - thus the if-return pattern. It's verbose and repetitive, but makes it clear what's the intention and consequence. The actual action of ignoring via Assert.Ignore is hidden from the person reading a specific unit test. It is implied by the name, but without checking what IgnoreUnsupportedConfiguration actually does, they don't know the consequences.
Unit tests are a peculiar thing, and I think verbosity (and code repetition) are perfectly fine there, even desired.

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

grendello added a commit that referenced this pull request Nov 7, 2025
grendello added a commit that referenced this pull request Nov 7, 2025
grendello and others added 27 commits November 7, 2025 18:41
@grendello grendello force-pushed the dev/grendel/test-runtimes branch from 3adffe6 to 98cb409 Compare November 7, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants