Skip to content

docs: add a rule for how tests in this repo are written - #54

Merged
lukaszstolarczuk merged 5 commits into
intel:mainfrom
lslusarczyk:docs/unit-test-writing-rules
Oct 28, 2026
Merged

lukaszstolarczuk merged 5 commits into
intel:mainfrom
lslusarczyk:docs/unit-test-writing-rules

Conversation

@lslusarczyk

@lslusarczyk lslusarczyk commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

The rule tells developers and agents to keep them dumb, specific, and tied to behavior.
It loads when a file under tests/ or conftest.py is in context.

Comment thread .cursor/rules/unit-tests.mdc Outdated
Comment thread .cursor/rules/unit-tests.mdc
Comment thread .cursor/rules/unit-tests.mdc Outdated
Comment thread .cursor/rules/unit-tests.mdc Outdated
Comment thread .cursor/rules/unit-tests.mdc Outdated
@PatKamin

Copy link
Copy Markdown
Contributor

In overall, please, make it more human-readable

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
A wrong test does not write a product bug. Examples catch the specific error type.
The torch.compile patch example mocked a library the rule forbids, so it is gone.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
Say the same rules in full sentences. Keep them short.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
@lslusarczyk

Copy link
Copy Markdown
Contributor Author

In overall, please, make it more human-readable

Done in the second commit. The first applies your comments. The second makes everything more human readable.

@PatKamin

Copy link
Copy Markdown
Contributor

I would describe additionally:

  • xfail rules - when it is allowed to use skip/xfail, always require an explanation message for skipping
  • create a file naming convention (I would give up current numbering in functional tests, i.e.)
  • enforce usage of id= in parametrized tests
  • perhaps expect a coverage goal to be met, this would require having rules/instructions on splitting test cases into smoke/functional/nightly or sth like that

Skip and xfail require a reason. New files are test_<behavior>.py.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
@lslusarczyk

Copy link
Copy Markdown
Contributor Author

I would describe additionally:

* xfail rules - when it is allowed to use skip/xfail, always require an explanation message for skipping
* create a file naming convention (I would give up current numbering in functional tests, i.e.)
* enforce usage of `id=` in parametrized tests
* perhaps expect a coverage goal to be met, this would require having rules/instructions on splitting test cases into smoke/functional/nightly or sth like that

Applied two first points.

skip and xfail always take reason. Skip only when this machine cannot run the test. xfail names a known defect.

A new file is test_<behavior>.py. No new sequence number. Renaming the existing 012_... files is a separate change.

ids on every parametrize should not be a rule. True and "256" already read clearly. Pass ids when the value's repr is not the case: a tensor, a module, a long tuple.

A coverage percentage are not in this rule. The repo does not measure coverage yet.

Comment thread .cursor/rules/unit-tests.mdc Outdated
A round trip is save, load, and forward. One behavior does not mean one call.

Signed-off-by: Łukasz Ślusarczyk <lukasz.slusarczyk@intel.com>
@lukaszstolarczuk
lukaszstolarczuk enabled auto-merge (squash) October 28, 2026 12:04
@lukaszstolarczuk
lukaszstolarczuk merged commit dc386a3 into intel:main Oct 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants