How-to integration test plugins

Continuing the discussion from Unit testing my plugin:

I’ve done some work re. how to do JUnit Integration tests for Sponge; have a look at Michael Vorburger's Blog v2: How to integration test Minecraft Server plugins using a custom JUnit Runner; if you think this could be useful, comment here or in Integration Test infrastructure: @RunWith(MinecraftRunner.class) · Issue #875 · SpongePowered/SpongeAPI · GitHub.

2 Likes

OK guys one question I have to push this investigation further: How would you would “simulate” a connected Player? Without actually starting a real MC GUI Client… that’s too heavy.

Say you wanted to use this @RunWith(MinecraftRunner.class) infrastructure to integration test e.g. some Command, assume say a simple /echo kinda command that just replies back, as an example, in this scenario, for a headless full stack integration test, where from would you get a Player (CommandSource) to pass as argument into a CommandService process, so that it can be replied to? Just mock a Player… but that won’t really be active in-world - there must be some better way to do this that I’m not seeing - thoughts?

PS: I did find the PlayerSimulator available on World, but that clearly has another purpose, and doesn’t actually implement Player/CommandSource, so that can’t be used for this.

1 Like

I’d say you could make a dummy class that extends Player. This, however, would not work for methods that require a UUID.