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 grendello force-pushed the dev/grendel/test-runtimes branch from 3adffe6 to 98cb409 Compare November 7, 2025 17:41
@grendello
Copy link
Contributor Author

/azp run

@grendello grendello force-pushed the dev/grendel/test-runtimes branch from 98cb409 to 6562ebf Compare November 12, 2025 08:53
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

grendello added a commit that referenced this pull request Nov 12, 2025
@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).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables more tests to run across all three Android runtimes (MonoVM, CoreCLR, and NativeAOT) by adding runtime parameters to test methods and implementing runtime-specific configuration handling.

Key Changes

  • Added helper methods in ProjectExtensions.cs to configure projects for specific runtimes, with special handling for NativeAOT
  • Introduced IgnoreUnsupportedConfiguration() in BaseTest.cs to skip tests for unsupported runtime/configuration combinations
  • Updated 40+ test methods in BuildTest.cs to accept an AndroidRuntime parameter and appropriately handle each runtime

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
ProjectExtensions.cs Refactored SetRuntime() with new overload for XamarinAndroidApplicationProject and extracted helper methods for NativeAOT handling
BaseTest.cs Added IgnoreUnsupportedConfiguration() to validate and skip unsupported runtime/build configurations (NativeAOT requires release, CoreCLR doesn't support AOT)
BuildTest.cs Expanded test coverage by adding AndroidRuntime parameter to numerous tests, with appropriate runtime configuration and validation logic

grendello added a commit that referenced this pull request Nov 13, 2025
grendello and others added 4 commits November 14, 2025 09:05
…sts/BuildTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
grendello added a commit that referenced this pull request Nov 17, 2025
grendello added a commit that referenced this pull request Nov 17, 2025
grendello added a commit that referenced this pull request Nov 17, 2025
grendello added a commit that referenced this pull request Nov 17, 2025
@jonathanpeppers jonathanpeppers merged commit aff261c into main Nov 17, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/grendel/test-runtimes branch November 17, 2025 20:08
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