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 real players to test suite #6319

Closed
wants to merge 4 commits into from

Conversation

Pikachu920
Copy link
Member

@Pikachu920 Pikachu920 commented Jan 11, 2024

Description

this PR adds real players to the test suite. the aim it to allow us to test complex things that require players and may not be possible or feasible to mock (e.g parsing uuids 😆). it works by downloading an open-source minecraft implementation Minosoft. a few headless minosoft instances are started in the background and are instructed to join the test server. the test server waits for them to connect before running the tests.

this is currently passing with the quickTest task on my win10 machine but not much else.


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@Pikachu920 Pikachu920 changed the base branch from master to dev/feature January 11, 2024 05:25
@Pikachu920
Copy link
Member Author

personally, i'm super excited about this because it'll help us test more things! that said, i do want to point out a potential pitfall: since minosoft is an open source project, it may lag behind in protocol support for new versions or even be abandoned completely. that would mean our player-related tests might not always be able to run on the latest versions immediately. one future alternative would be using the vanilla client prismlauncher, but the "connect to server on launch" option is currently broken. i think once that is fixed (see PrismLauncher/PrismLauncher#1164), we could feasibly switch to this method instead.

@TheLimeGlass
Copy link
Contributor

TheLimeGlass commented Jan 11, 2024

I don't know if this would necessarily be needed, as we should currently be using EasyMock to mock a player instance with what we need. Njol did this in the past. It's certainly cool, but it relys on a third party application and forces the tests to be in offline mode which isn't a good thing for other tests, and it's security of the clients is also reliant on the third party.

@Pikachu920
Copy link
Member Author

I don't know if this would necessarily be needed, as we should currently be using EasyMock to mock a player instance with what we need. Njol did this in the past. It's certainly cool, but it relys on a third party application and forces the tests to be in offline mode which isn't a good thing for other tests, and it's security of the clients is also reliant on the third party.

definitely valid points. I think there is still value in this but i'd love to work on it some more and see what others think. could you pls elaborate on offline mode being bad for other tests?

@TheLimeGlass
Copy link
Contributor

definitely valid points. I think there is still value in this but i'd love to work on it some more and see what others think. could you pls elaborate on offline mode being bad for other tests?

UUID tests, skull tests, skin tests, server list syntaxes, player comparison, etc.

@AyhamAl-Ali AyhamAl-Ali added unit testing For issues/PRs related to the Skript unit testing system. enhancement Feature request, an issue about something that could be improved, or a PR improving something. labels Jan 20, 2024
@sovdeeth
Copy link
Member

Do you still intend to work on this?

@Pikachu920
Copy link
Member Author

Do you still intend to work on this?

yes, I think I have a new approach that addresses lime's concerns. We can add it as a new test mode so that some tests can run in online mode and some can run with players. for example:

test "uuid parsing" if server is is online mode:
  assert name of "my uuid" parsed an offline player is "me" with "failed to parse uuid into offlineplayer"
  
test "push player" if size of all players > 0:
  set {_player} to a random player out of all players
  push {_player} with speed 1
  assert velocity of {_player} is greater than vector({_whatever}, {_whatever}, {_whatever}) with "Failed to push player"

@sovdeeth
Copy link
Member

Do you still intend to work on this?

yes, I think I have a new approach that addresses lime's concerns. We can add it as a new test mode so that some tests can run in online mode and some can run with players. for example:

It has now been 11 months with no updates, so I'm closing for inactivity @Pikachu920

@sovdeeth sovdeeth closed this Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. unit testing For issues/PRs related to the Skript unit testing system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants