/xwiki:xwiki-convert-tests-dockerfrom xwiki
Converts XWiki functional IT tests from JUnit4 legacy framework to JUnit5 Docker-based framework (@UITest). Covers module setup, @UITest configuration, WAR composition, and repository setup.
Ships in xwiki. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when converting existing tests that use the JUnit4 legacy functional test framework (based on AbstractAuthenticatedTest, getUtil(), getRepositoryTestUtils(), etc. from xwiki-platform-test-ui) to JUnit5 Docker-based tests using @UITest.
For converting unit tests (JUnit4/JMock → JUnit5/Mockito), use the xwiki-convert-tests skill instead.
Load xwiki-test-guidelines too: its rules for writing a test still apply to the converted one.
Lay out the new modules as the "Functional-test module layout" section of kb/testing/strategy.md
describes, via the xwiki-knowledge skill. It covers the -test / -test-pageobjects /
-test-docker modules and their profiles, the -test-docker pom, the AllIT entry point with a
@UITest on every test class, and where @since goes. Create the -test-docker module in the
feature's existing -test module, next to the legacy test module it replaces.
The @UITest annotation on the IT class configures the Docker test environment:
Prefer pom dependencies over
extraJARs. The feature modules a test needs should be declared as normal (runtime) dependencies in the test pom — the framework installs them as runtime extensions (see "The minimal WAR" below). Reach forextraJARsonly as a last resort, for JARs that must be physically present inWEB-INF/libat WAR startup (e.g. a repository factory or index provider needed during bootstrap, before extensions are installed). The example below is exactly that last-resort case.
@UITest(
extraJARs = {
// Last resort: these are needed in WEB-INF/lib at WAR startup, before runtime extension
// installation, so they can't be provided as ordinary pom dependencies (which install as
// extensions). Everything else belongs in the pom as a runtime dependency instead.
"org.xwiki.commons:xwiki-commons-extension-repository-xwiki",
"org.xwiki.platform:xwiki-platform-extension-index"
},
properties = {
// Append properties to xwiki.properties (does NOT replace defaults).
// Use this to configure extension repositories, feature flags, etc.
"xwikiPropertiesAdditionalProperties=extension.core.resolve=false\n"
+ "extension.repositories = self:xwiki:http://localhost:8080/xwiki/rest"
}
)
class FeatureIT { ... }
| Parameter | Purpose |
|---|---|
extraJARs | JARs added to WEB-INF/lib. Last resort — only for components that must be present at WAR startup, before runtime extension installation (e.g. repository factories, index providers). For everything else, declare a pom dependency instead. Format: "groupId:artifactId" |
properties | Entries added to TestConfiguration. xwikiPropertiesAdditionalProperties appends lines to xwiki.properties |
offline | When true, configures Maven in offline mode; only maven-local repository is set in xwiki.properties |
xwikiExtensionRepositories | REPLACES the full extension repository list. Prefer xwikiPropertiesAdditionalProperties to APPEND repositories instead |
To use BOTH the local Maven repo AND the XWiki self-hosted repo (for test extensions served via REST), use xwikiPropertiesAdditionalProperties to append the self repo. Apache Commons Configuration2 accumulates duplicate extension.repositories keys into a list:
# Generated by offline=true:
extension.repositories = maven-local:maven:file:///~/.m2/repository
# Appended via xwikiPropertiesAdditionalProperties:
extension.repositories = self:xwiki:http://localhost:8080/xwiki/rest
Why not xwikiExtensionRepositories? It's not in KNOWN_LIST_KEYS so it replaces rather than appends. xwikiPropertiesAdditionalProperties always appends.
WARBuilder builds a minimal WAR from xwiki-platform-minimaldependencies. What this means:
WEB-INF/lib: only the core components in minimaldependencies (and their
transitive deps) plus any extraJARs from @UITest.ExtensionInstaller
reads the test pom's non-test-scope jar/xar dependencies and installs each as a runtime
extension into the running XWiki — skipping any artifact already bundled in the minimal WAR
(ExtensionInstaller.getProjectExtensionIds()). So declaring an already-bundled dependency is
harmless (it's auto-skipped), and declaring a missing one gets it installed correctly. This is why
the deps-first rule above works: just declare the feature modules under test as runtime
dependencies.Migrating from a packager-based -tests module: don't blindly carry over its runtime deps. Keep
only what the feature actually needs at runtime; drop infrastructure deps the minimal WAR already
provides (e.g. xwiki-platform-search-solr-embedded for a test that does no search).
Common extraJARs (the last-resort, startup-time case) needed for extension-related tests:
org.xwiki.commons:xwiki-commons-extension-repository-xwiki — provides XWikiExtensionRepositoryFactory for the xwiki: repository type. Without it: startup error "Unsupported repository type [xwiki]".org.xwiki.platform:xwiki-platform-extension-index — Solr-backed extension search. Without it: NullPointerException in Solr client, keyword searches return 0 results.The WARBuilder assembles the test WAR by:
minimaldependencies (including xwiki-platform-web-war)WEB-INF/libsrc/test/webapp/ in the test moduleTo override a template or resource in the test WAR, place the file under src/test/webapp/ with the same relative path as in the deployed WAR:
src/test/webapp/templates/my_template.vm → webapps/xwiki/templates/my_template.vm
This is the clean way to test against modified templates without rebuilding the entire distribution.
When you modify a template in xwiki-platform-web-templates, you must also rebuild xwiki-platform-web-war for the change to appear in the Docker test WAR:
mvn clean install -B -ntp -pl xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates \
-DskipTests
mvn clean install -B -ntp -pl xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war \
-DskipTests
The Docker test's mvn clean verify then picks up the updated xwiki-platform-web-war JAR from the local Maven repo.
@UITest(...)
class FeatureIT
{
// Static fields shared across all tests in this class
private static RepositoryTestUtils repositoryTestUtils;
private static ExtensionTestUtils extensionTestUtils;
@BeforeAll
static void beforeAll(TestUtils setup) throws Exception
{
setup.loginAsSuperAdmin();
setup.recacheSecretToken();
setup.setDefaultCredentials(TestUtils.SUPER_ADMIN_CREDENTIALS);
repositoryTestUtils = new RepositoryTestUtils(setup, new RepositoryUtils(), new SolrTestUtils(setup));
repositoryTestUtils.init(); // generates test extension files
extensionTestUtils = new ExtensionTestUtils(setup);
}
@BeforeEach
void setUp(TestUtils setup) throws Exception
{
setup.loginAsSuperAdmin();
// Cleanup state from previous test
extensionTestUtils.uninstall("my-extension");
repositoryTestUtils.deleteExtension("my-extension");
repositoryTestUtils.waitUntilReady();
// Verify clean state
ExtensionsSearchResult result = setup.rest().getResource("repository/search", ...);
assertEquals(0, result.getTotalHits());
}
@Test
@Order(1)
void testSomething(TestUtils setup) throws Exception
{
// ...
}
}
Key differences from JUnit4:
TestUtils setup is injected as a method parameter, not accessed via getUtil()@BeforeAll static methods also receive TestUtils as a parameter@Order controls test execution order (important: tests often depend on previous state)| JUnit4 | JUnit5 Docker |
|---|---|
getUtil() | setup (injected parameter) |
getRepositoryTestUtils() | repositoryTestUtils (static field, initialized in @BeforeAll) |
getExtensionTestUtils() | extensionTestUtils (static field) |
// Installing an extension programmatically (bypassing UI)
extensionTestUtils.install(new ExtensionId("my-extension", "1.0"));
// Uninstalling
extensionTestUtils.uninstall("my-extension");
// Wait for Solr index to be ready after adding test extensions
repositoryTestUtils.waitUntilReady();
TestExtension extension = repositoryTestUtils.getTestExtension(
new ExtensionId("alice-xar-extension", "1.3"), "xar");
// Optionally override the auto-set name (defaults to artifact ID):
extension.setName("Alice Wiki Macro");
repositoryTestUtils.addExtension(extension);
TestExtension constructor sets name to id.getId() (the artifact ID string). Override with setName() when tests assert on the display name.
As of commit 891f2b563011 (XWIKI-24145), the log collapse toggle changed from <label> to <button>. The XPath in ExtensionProgressPane.getJobLogLabel() must use /button:
// Correct for current codebase:
String xpath = "//*[@class = 'log']/parent::dd/preceding-sibling::dt[last()]/button";
Any <button class="collapse-toggle"> inside an extension <form class="extension-item"> must have type="button". Without it, the button defaults to type="submit" and clicking it submits the extension form, causing a DOM replacement and StaleElementReferenceException in tests that access elements after the click.
Template: job_macros.vm, macro displayJobStatusLog:
<button type="button" class="btn btn-default btn-xs collapse-toggle...">
The minimal Docker WAR contains a different set of core extensions than a full XWiki installation. For example, it contains org.apache.groovy:groovy (name: "Apache Groovy") as the groovy runtime, not xwiki-platform-groovy or xwiki-commons-groovy. Adjust assertions accordingly:
// Full XWiki: > 1 groovy extensions (XWiki wrappers + groovy itself)
// Minimal Docker WAR: only 1 groovy-related extension
assertTrue(searchResults.getDisplayedResultsCount() >= 1);
# Full run including Docker functional tests
mvn clean verify -B -ntp \
-pl xwiki-platform-core/xwiki-platform-<feature>/xwiki-platform-<feature>-test/xwiki-platform-<feature>-test-docker \
-Pintegration-tests,docker \
-Dxwiki.checkstyle.skip=true \
-Dxwiki.surefire.captureconsole.skip=true \
-Dxwiki.revapi.skip=true
The docker profile is needed to activate the test module (see parent pom.xml configuration above).
Results in: target/failsafe-reports/TEST-*.xml
Screenshots on failure in: target/screenshots/ or in the test output directory named after the test configuration.
The default mvn clean verify runs above execute the Maven build on the host with XWiki on the
default Jetty Standalone engine. That does not need to be repeated separately — instead, validate
the converted test with the DOOD (Docker-out-of-Docker) setup, which exercises everything more
thoroughly in one run. The CI agents run the whole build inside the xwiki/build Docker image, and
that build then spawns the test's servlet-engine / database / browser containers as siblings on the
host Docker daemon. This is enabled by bind-mounting the host's Docker socket into the build
container (-v /var/run/docker.sock:/var/run/docker.sock), so the Docker client inside the container
talks to the host daemon. Running this setup (e.g. on Tomcat) surfaces issues that only appear when
the build itself is containerized (paths, socket access, container-to-container networking) as well as
those from XWiki running inside a container (the local Maven repo must be reached over http://
rather than file://).
Reference (don't duplicate): the full, up-to-date instructions and per-flag explanations live in the xwiki-docker-build "Local usage" doc. Salient points:
xwiki/build image (on DockerHub) bundles the required build tools: Java 17, the
latest Maven, a Docker client, Firefox, and a VNC server.-v $HOME/.m2:/root/.m2:delegated) to avoid re-downloading dependencies, and the
module source (e.g. -v `pwd`:/root/`basename \`pwd\:delegated``) to build your local changes.DISPLAY
(the doc also covers forwarding the display to a Mac/Linux host via XQuartz/X11).Minimal interactive shell inside the build container, then run the test as usual from there:
# On the host: get a shell inside the xwiki/build container with the Docker socket mounted (DOOD).
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/.m2:/root/.m2:delegated \
-v "$(pwd)":/root/"$(basename "$(pwd)")":delegated \
--entrypoint "/bin/bash" xwiki/build
# Inside the container: start a display, then run the Docker test (Tomcat shown for the DOOD path).
vncserver :1 -geometry 1280x960 -localhost -nolisten tcp && export DISPLAY=:1
cd /root/<module-dir>
mvn clean verify -B -ntp \
-pl xwiki-platform-core/xwiki-platform-<feature>/xwiki-platform-<feature>-test/xwiki-platform-<feature>-test-docker \
-Pintegration-tests,docker \
-Dxwiki.test.ui.servletEngine=tomcat \
-Dxwiki.checkstyle.skip=true \
-Dxwiki.surefire.captureconsole.skip=true \
-Dxwiki.revapi.skip=true
mvn clean verify with the docker profile and confirm 0 failures, 0 errors.xwiki/build container (Docker socket mounted, e.g. on Tomcat) — this matches how CI runs it and validates everything in one run. See "Verify the DOOD use case" above.@Order values cover the expected dependency chain between tests.kb/testing/strategy.md). Keep a reset a later assertion depends on, as above.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
xwiki, junit5, docker-testing, functional-tests, test-migration
npx claudepluginhub xwiki/xwiki-dev-llm --plugin xwiki38 skills in this plugin
/xwiki-backportBackport any change (bug fix, feature, refactor, or test) to an older branch of an XWiki repo (xwiki-platform / xwiki-commons / xwiki-rendering / xwiki-contrib). Cherry-pick `-x` the source commit(s) into a worktree, ADAPT the result to the older branch (module pom versions, Java level, `@since` tags, data migration versions and skip ranges, style/API divergence), verify it compiles against that branch, and push / open a PR. Use whenever a commit that exists on one branch needs to be applied to an older/maintenance branch. For the `testneeded`-labelled test sweep use xwiki-backport-testneeded (which builds on this skill); for Maven commands use xwiki-build; for PR/commit conventions use xwiki-pull-request; for the versioning/`@since` conventions (the format and what carries `@since`) use xwiki-knowledge./xwiki-backport-testneededBackport the automated test of one JIRA issue labelled `testneeded` to the currently-supported stable branches, adjust its `@since` tags across all branches, and open the PRs. Use when asked to backport the test of a given testneeded issue, or to catch a stable branch up with a recently-added test. (For several issues at once, the user will say so — then apply this per issue.) This is the test-specific layer on top of xwiki-backport (which owns the generic cherry-pick / adapt-to-branch / verify mechanics — including the mandatory pom-version, Java-version and `@since` checks). For Maven use xwiki-build; for PR/commit conventions use xwiki-pull-request; for the `@since` rules use xwiki-knowledge; for querying JIRA (the testneeded sweep) use xwiki-jira.