Skip to content

Add a Testing chapter for backend packages#2094

Open
jensens wants to merge 3 commits into
6.0from
backend-testing-docs
Open

Add a Testing chapter for backend packages#2094
jensens wants to merge 3 commits into
6.0from
backend-testing-docs

Conversation

@jensens

@jensens jensens commented Jul 15, 2026

Copy link
Copy Markdown
Member

Why

Plone 6 has no backend testing documentation. The Developer guide has no Testing section (only Volto testing, under Contributing), and the only rendered HTML for plone.testing and plone.app.testing lives on the legacy 5.docs.plone.org domain.

@davisagli sketched a full outline for such a chapter in a comment on plone/pytest-plone#16 about two years ago, covering Volto/Jest/Cypress, unittest/zope.testrunner, pytest, Robot, and testbrowser. This PR picks up the two pieces of that outline that cover backend Python testing and deliberately leaves the rest to build on top. Please treat the structure as a starting point — I expect there are opinions on placement, and I am happy to move things.

What

Five pages, Diataxis-classified:

Explanationconceptual-guides/testing.md
: The kinds of tests (unit / integration / functional / acceptance), why Plone has testing layers at all, and how to choose between the two runners.

How-todeveloper-guide/testing/
: - write-a-testing-layer.md — the keystone, placed first: writing the testing.py layer both runners share. Shows the declarative PloneWithPackageLayer form for simple add-ons and the PloneSandboxLayer subclass form for complex ones.
: - zope-testrunner.md — write and run tests with unittest and zope.testrunner.
: - pytest.md — write and run tests with pytest, linking to the published pytest-plone documentation.

Scope

  • Backend Python only. Volto testing lives in the Volto repository and is cross-referenced, not duplicated.
  • The deep API reference for the layer machinery stays in plone.app.testing / plone.testing; the how-to links there rather than reproducing it.
  • A follow-up could modernize and host those two package docs, then link the hosted versions from here.

Verification

  • Every zope-testrunner command shown was executed against a real package. The two layer forms are taken from real coredev packages (plone.app.dexterity, plone.volto) and the plone.app.testing README, with every import checked against the installed packages.
  • Vale reports 0 errors, 0 warnings, 0 suggestions on the new pages; the vocabulary additions it needed are included.
  • make html produces no new warnings, and linkcheck finds no broken links on the new pages.

Related

Companion to the newly published pytest-plone documentation (plone/pytest-plone#56), which this chapter's pytest guide links to.

jensens added 2 commits July 15, 2026 12:38
Plone 6 has no backend testing documentation. The Developer guide has no
Testing section, and the only rendered HTML for plone.testing and
plone.app.testing lives on the legacy 5.docs.plone.org domain.

@davisagli sketched a full outline for such a chapter in a comment on
plone/pytest-plone#16 two years ago. This picks up the two pieces of it
that cover backend Python testing, and deliberately leaves the rest --
Volto, Robot Framework, testbrowser -- to build on top.

- conceptual-guides/testing.md explains the kinds of tests, why Plone has
  testing layers at all, and how to choose between the two runners.
- developer-guide/testing/ shows how to write and run tests with either
  zope.testrunner or pytest.

The pytest guide links to the published pytest-plone documentation at
plone.github.io/pytest-plone. Volto testing is cross-referenced rather
than duplicated: it lives in the Volto repository.

Every zope-testrunner command shown was executed against a real package
before being documented. Vale reports 0 errors, 0 warnings, and 0
suggestions on the new pages; linkcheck confirms every external link
resolves.
Writing the testing.py layer is the setup work both zope.testrunner and
pytest-plone build on, and the chapter previously punted it to the large
plone.app.testing README. That left the developer guide without its
keystone: the one thing every backend test needs.

Add developer-guide/testing/write-a-testing-layer.md, placed first in the
sub-toctree because it is the shared prerequisite. It shows both forms:

- the declarative PloneWithPackageLayer instance, for a simple add-on;
- the PloneSandboxLayer subclass with setUpZope/setUpPloneSite, for
  anything more involved.

Both forms, and the WSGI_SERVER_FIXTURE note for real-HTTP functional
tests, are taken from real coredev packages (plone.app.dexterity,
plone.volto) and the plone.app.testing README, and every import was
checked against the installed packages. The runner guides and the
conceptual guide now point here instead of at the README.

Also drop the code-span from the zope.testrunner headings, which
rendered as a heavy monospace box next to the plain 'pytest' heading.

@gforcada gforcada left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! 🌟

Comment thread styles/config/vocabularies/Plone/accept.txt Outdated
Comment thread docs/conceptual-guides/testing.md Outdated
Comment thread docs/conceptual-guides/testing.md Outdated
Comment thread docs/developer-guide/testing/pytest.md
Comment thread docs/developer-guide/testing/zope-testrunner.md Outdated
- Sort the Vale vocabulary additions into place instead of appending
  them, and trim them to the terms actually needed (the class names only
  ever appear in code spans, which Vale does not check).
- Do not pin Cypress for the Volto frontend; the frontend tooling is in
  flux, so defer to the Volto documentation instead.
- Recommend 'zope-testrunner --test-path src -s <pkg>', the form the
  plone.meta tox environments use, and keep --auto-path as the
  pip-installed alternative. (Thanks @gforcada -- the original --auto-path
  lead came from buildout.coredev's run-tests.sh, not the common case.)
- Note that pytest --cov needs the pytest-cov plugin installed.
- Backtick pytest in the 'Choosing' section for consistency with
  zope.testrunner.
@jensens

jensens commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review, @gforcada! All five addressed in the last commit:

  • --test-path vs --auto-path — you're right, and thanks for catching it. My --auto-path lead came from buildout.coredev's run-tests.sh, not the common case. The primary command is now zope-testrunner --test-path src -s my.addon (the form the plone.meta tox environments generate), with --auto-path kept as the pip-installed-in-dev-mode alternative. Verified both run.
  • Cypress for Volto — agreed the frontend tooling is in flux (Cypress → Playwright, Aurora, …). I dropped the specific tool and defer to the Volto documentation instead, so this backend page does not go stale on a frontend decision. Happy to add a concrete link if there's a canonical Volto testing page to point at.
  • pytest --cov — added a pip install pytest-cov note.
  • Vocabulary sorting — sorted the additions into place, and trimmed them: the class names only ever appear in code spans, which Vale does not check, so they were never needed. Down to the terms that actually appear in prose.
  • Backtick pytest — applied your suggestion.

Vale is back to 0/0/0 on the five pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants