PaperMC / PaperMC/Paper

Provide mechanism to bootstrap Paper for unit testing

Open
#12,331 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: needs triage
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Is your feature request related to a problem?

Back in the day I would build Spigot locally and add it as a test dependency. This allowed me to write unit tests for my plugins that, quite frankly, never steered me wrong.

I stuck with making "spigot plugins" for a very long time because I couldn't reasonably do the same with Paper. As Paper has diverged, and now has hard-forked, I've had to make the switch and there is much I can no longer unit test.

Describe the solution you'd like.

I'd like to be able to add Paper as a test dependency, even if I have to build it locally to make it work, and for Paper to expose a simple static method tests can call that will bootstrap Paper, all the registries, all the enum replacements (Biomes, PotionEffects, etc.), and allow plugin developers to properly unit test their code.

Describe alternatives you've considered.

MockBukkit - it's a nice attempt but it will NEVER have parity with the real thing. I'm constantly running into gaps and non-parity issues I'm having to PR into that framework - and there are gaps I simply cannot fill with MockBukkit (serialize to/from bytes on anything for example).

I have my plugin logic split into a core library that I build, and unit test, against Spigot, but this is limiting and more and more of my library code is shifting up into my Paper core library where my ability to test is spotty at best.

I've gone to painful lengths to use reflection to bootstrap parts of Paper but it's a losing battle with high upkeep - and the use of final methods in some classes like JavaPlugin simply can't be mocked making this process all the more tedious.

Other

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The request names no Paper files, tests, or build entry points; begin by locating Paper’s existing test and build setup, then review the reflection-based bootstrap and JavaPlugin limitations mentioned in the issue. Done would mean a callable bootstrap path for plugin tests, with Paper registries and enum replacements available through a test dependency and covered by unit tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.