Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end-to-end test framework inspired from iOS interactive tests #8390

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Mindfulplays
Copy link
Contributor

This brings interactive tests from iOS and allows them to be run in any environment.
Specifically, given a set of Game classes under Tests/Interactive/Tests, we can run that Game instance in a test harness under DesktopGL (Mac/Windows)/iOS (Android coming next).

  • Lots of reshuffling from Tests/Interactive/iOS -> Common/Tests
    • Also added doc to run the tests in simulator/on-device.
  • New TestRunners (for now DesktopGL on Mac/Windows and iOS)- will add Android next
    • DesktopGL only allows running one test per run, due to STA/SDL Window event loop.
    • Perhaps consider NUnit test that launches the DesktopGL in a separate process with the correct command-line parameter?
  • Added doc in Tests/Interactive/README.md on how to run the test runners.
  • Allows 'automatic' running of InteractiveTests too (i.e. automatically run one test, allow test to signal 'finish' and exit)
    • i.e. provided a TestGame that implements Game and allows a test author to signal when the test is done. (i.e. either by clicking the Exit button or the test can run automatically, then signal Exit)

This brings interactive tests from iOS and allows them to be run in any environment.
Specifically, given a set of `Game` classes under `Tests/Interactive/Tests`,
we can run that `Game` instance in a test harness under DesktopGL (Mac/Windows)/iOS (Android coming next).

- Lots of reshuffling from Tests/Interactive/iOS -> Common/Tests
  - Also added doc to run the tests in simulator/on-device.
- New TestRunners (for now DesktopGL on Mac/Windows and iOS)- will add Android next
  - DesktopGL only allows running one test per run, due to STA/SDL Window event loop.
  - Perhaps consider NUnit test that launches the DesktopGL in a separate process with the correct command-line parameter?
- Added doc in Tests/Interactive/README.md on how to run the test runners.
- Allows 'automatic' running of InteractiveTests too (i.e. automatically run one test, allow test to signal 'finish' and exit)
  - i.e. provided a `TestGame` that implements `Game` and allows a test author to signal when the test is done. (i.e. either by clicking the Exit button or the test can run automatically, then signal Exit)
@Mindfulplays
Copy link
Contributor Author

@dellis1972 @SimonDarksideJ Please take a look. I would like an initial pass to see if this is even worth it.
Otherwise, I can keep it in my 'metal' repo (https://github.com/Mindfulplays/MonoGame/tree/ios-metal).

This also doubles as a test tutorial for newbies to quickly test DesktopGL/iOS etc (especially specific things like alpha blend test or render target test as these are common questions in discord/forums).

It's also pretty well aligned with the bounty to add tutorial(s) although I am not partaking in that.

@Mindfulplays
Copy link
Contributor Author

To start, please look at README.md which is a good starting point.

}

/// <summary>Output an error message to the console.</summary>
public static void E(string message)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I mentioned this on the other PR.
It might be better to have actual descriptive method names like LogError or Error. Same for the C method. Looking at the code which is calling it , it is not obvious what the method does GameDebug.C ("foo") could be doing anything, so you have to go look.

In this case C might be better being called Log or Debug.

Copy link
Contributor Author

@Mindfulplays Mindfulplays Jun 17, 2024

Choose a reason for hiding this comment

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

NVM, this is the *test* specific logging, not `GraphicsDebug` - I will make this change as the test doesn't require conciseness - I favor readability to conciseness in the test. (Edited comment )

Before edit: I was going for the minimal [Android-y](https://developer.android.com/reference/android/util/Log) `Log` that are concise and help avoid cognitive overload when reading a bunch of the logging statements.

If the xmldoc comment doesn't help (on hover for example), I am okay with changing it to be a bit longer like you suggest. But I wanted to provide you a rationale first.

It also helps with using GD=GraphicsDebug; GD.E("..."); etc which makes it super concise.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the rationale. I would favour consistencey though, most of the logging in the repo uses things like Debug.WriteLine or Log.Verbose etc (see https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Platform/Android/MonoGameAndroidGameView.cs#L778). Keeping code consitent with other uses within the repo makes it easier to people to understand the code as a whole. This is my preference, we can see what other @MonoGame/maintainers think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would agree with @dellis1972 , as this is the standard used by the rest of MonoGame.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done PTAL, thanks!

private static readonly Dictionary<string, MessageCount> MESSAGES_COUNTS_ = new();

/// <summary>Use this to output spammy messages.</summary>
public static void Spam(string message, int maxNumTimes = 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pinging :) Could you please take a look? Thanks!

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.

None yet

3 participants