Improve docs around setUp and setUpBeforeClass

Open
#38 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Domain
documentation

Research direction

Open docs/en/02_Developer_Guides/06_Testing/00_Unit_Testing.md and review the setUp and setUpBeforeClass sections, using the linked blame context. Confirm the current SapphireTest method visibility and document the setup caveats described in the issue; done means the guidance is accurate and clearly warns about test-state persistence.

Written by the indexing model from the issue text.

Description

affects/v4 complexity/low impact/low type/docs

Description

The docs for setUp and tearDown in SapphireTest are incorrect as these methods are protected now.

Additionally the docs have a section about using setUpBeforeClass in your tests:

https://github.com/silverstripe/silverstripe-framework/blame/4/docs/en/02_Developer_Guides/06_Testing/00_Unit_Testing.md#L140 (blame because there's no line-number view for markdown files 😞 )

This doesn't mention any of the caveats of using this like certain scaffolding not being ready yet - the example from community Slack being you can't Security::setCurrentUser. Personally I would generally discourage use of it in most cases as test state should not persist between individual tests.

Either way that section could be improved to warn developers better.

Dominant language
No language data
Stars
7
Forks
74
Avg merge
1d 14m
Merged PRs (30d)
6

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.

More from silverstripe/developer-docs

All issues in silverstripe/developer-docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.