Hi devs,
While reviewing some LLM guidance, @MichaelHamann pointed out that CKEditor (page object) has carried @Unstable for 9 years and ForgotUsernameCompletePage has @Unstable methods that are 5 years old. Nothing fails because Checkstyle (and thus UnstableAnnotationCheck) is skipped in those modules. I checked and we never decided what test code is regarding API rules. The only discussion I found is Support retro-compatibility for page objects (Jan 2016): Guillaume proposed to treat POs as API, Marius found it too much of a burden, Thomas suggested to rather take better care of TestUtils and friends. It ended without a vote.
Current state (inconsistent)
- Test modules in platform (
*-testparents): 57 of 69 skip both Revapi and Checkstyle (“we don’t consider them as public APIs”), 9 page-object modules skip Revapi but run Checkstyle (so the@Unstablecheck). xwiki-platform-test-*(test-ui, test-docker, etc.): Revapi skipped, Checkstyle runs.xwiki-commons-tool-test-*: Revapi skipped (all ofxwiki-commons-toolsskips it), Checkstyle runs.xwiki-rendering-test: Revapi and Checkstyle both run, i.e. it’s treated as API today.src/test: no@Unstabletoday (only the checker’s own test fixtures). However 34 modules publish theirsrc/testas atest-jarused by other modules, e.g.MockitoOldcorelives in oldcore’ssrc/test.- JIRA: there’s a “Test Framework” component in XWIKI and a “Test” one in XCOMMONS/XRENDERING, but none for page objects, and we don’t strictly create issues for test framework changes.
- Usage outside our core repos is real: among the contrib repos I have locally, 36 use the platform test frameworks and 23 import page objects from platform.
Proposal
- Test code (
src/test, including code published as atest-jar) is never API. No@Unstable, no deprecation/legacy cycle, no JIRA issue required for changing it. This is mostly writing down what we already do. Reusable test code that is meant to be a test framework (shared by several modules) should be extracted into its own module, undersrc/main, rather than stay insrc/testand be shared as atest-jar; it then falls under 2. - Test frameworks (
src/mainofxwiki-commons-tool-test-*,xwiki-rendering-test,xwiki-platform-test-*, etc.) are not API. Same rules as 1. Rationale: most usage is ours, a break only affects developers at build time when they upgrade their parent version (never users at runtime), and the cost of the full API process (Revapi ignores,@Unstable, deprecation, legacy modules) isn’t worth it. Best effort is still expected: prefer deprecating over removing when it’s cheap, since contrib extensions use them. - Page objects (
src/mainof*-test-pageobjects) are not API. Same rules and rationale as 2.
For 2 and 3, I propose that we keep requiring @since on new public classes and methods, since it’s cheap and it tells contrib developers which parent version they need.
Consequences if agreed
- Remove the existing
@Unstableannotations on page objects (7 classes today). - Align the poms: skip Revapi on all test framework and page-object modules (
xwiki-rendering-testincluded). I’d rather enable Checkstyle on all of them (we lose all style checks on POs today, not just the@Unstableone), which would also catch any new@Unstable. - JIRA: no issue required for changes to 1-3. Keep using the “Test Framework” component for changes worth announcing to extension developers (new features of the test framework), but it’s optional.
- Document this on https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#H40UnstableAnnotation
Here’s my +1 for 1, 2 and 3.
WDYT?
Thanks