Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .agents/rules/test-infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ The rule: **if production modules already wire a component, use them — don't c
- Add tests to existing test files rather than creating new ones
- **Do not duplicate test methods that differ only in parameters** — use `[TestCase(...)]` or `[TestCaseSource(...)]` to parameterize a single method
- Before writing a new test, check if an existing test can be extended with another `[TestCase]` or use `[TestCaseSource]`
- **When only parts of tests are similar** — extract the shared parts into helper methods or types instead of copy-pasting:
- Shared arrange/build steps → a private helper method, an existing builder (`Build.A.Block...`, `Build.A.Transaction...`, `TestItem.*`), or a new builder if the pattern is reused across files
- Shared assertions → a helper method like `AssertExpectedState(...)` so each test asserts in one line and the failure message stays meaningful
- Shared scenarios spanning multiple test classes → a base fixture, a shared `static` helper class, or a fixture-level `[SetUp]`
- Keep each test body focused on what makes the case unique; the helper should not hide behavior that matters for understanding the test
- Use `[TestCaseSource]` (not `[TestCase]`) when cases need non-constant data, named scenarios, or grow beyond a handful — keep the source method or `IEnumerable<TestCaseData>` next to the test it feeds

## DotNetty `IByteBuffer` in tests

Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ This guide helps to get started with the Nethermind Ethereum execution client re
- Keep changes minimal and focused — don't touch unrelated code
- When fixing a bug, always add a regression test
- Do not alter [src/bench_precompiles](./src/bench_precompiles/) or [src/tests](./src/tests/)
- Avoid code duplication, especially in tests:
- When tests differ only by inputs and expected outputs, parameterize a single test with `[TestCase(...)]` or `[TestCaseSource(...)]` rather than copy-pasting the body. Before adding a new test, check whether an existing one can be extended with another `[TestCase]`.
- When only _parts_ of tests are similar (shared setup, common assertions, recurring scenarios), factor those parts into helper methods or helper types (e.g. a builder, a shared static helper, a test fixture base). Keep each test body focused on what makes the case unique.
- See [`.agents/rules/test-infrastructure.md`](./.agents/rules/test-infrastructure.md) "Test guidelines" for details.

---

Expand Down