Skip to content

Add more test writing instructions to AGENTS.md#780

Open
alex-clickhouse wants to merge 6 commits into
mainfrom
alex-clickhouse-patch-2
Open

Add more test writing instructions to AGENTS.md#780
alex-clickhouse wants to merge 6 commits into
mainfrom
alex-clickhouse-patch-2

Conversation

@alex-clickhouse

Copy link
Copy Markdown
Contributor

Ran into some issues when testing agentic bug fixes, hopefully this will lead the agent to behave a bit better :)

Signed-off-by: Alex Soffronow Pagonidis <alex.soffronow@clickhouse.com>
Signed-off-by: Alex Soffronow Pagonidis <alex.soffronow@clickhouse.com>
Comment thread AGENTS.md
- Inspect existing tests covering similar areas to make sure you are writing tests in the right style and with the right coverage.
- Make sure to test both the happy path as well as sad paths. Make sure to cover all relevant edge cases.
- When testing types, cover the full type matrix: ClickHouse type hints compose and formatting is recursive, so a change to how a value is formatted must be tested across all the shapes it can take: scalar, Array(T), Tuple(...), Array(Tuple(...)), Nullable(T), and spelling and case variants of the type name.
- Aim to be complete, but also terse. Don't use two tests to cover what could be done in one.

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.

Do we have any noteworthy patterns for parametrized tests that we should point out?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I'll leave in a separate comment.

@joe-clickhouse joe-clickhouse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Regarding the test matrix stuff, I'd add one calling out how to paramaterize a test.

  • Express a matrix of cases with @pytest.mark.parametrize rather than near-duplicate test bodies. This satisfies the terseness goal below and is the right place for the type-shape and case-variant coverage above.

And then another specifically bringing up the fact that sync and async client can use a paramaterized fixture to test both one a single test.

  • Client behavior must hold for both the sync and async clients. For integration tests use the param_client and call fixtures from tests/integration_tests/conftest.py, which run one test body against both transports via the client_mode parameter. See tests/integration_tests/test_temporal.py for the pattern. Do not write a sync-only test for a change that touches shared client code.

Signed-off-by: Alex Soffronow Pagonidis <alex.soffronow@clickhouse.com>
@alex-clickhouse

Copy link
Copy Markdown
Contributor Author

Don't merge this yet pls, I'm running some experiments and they'd be contaminated if we changed AGENTS.md mid-way through.

@joe-clickhouse

Copy link
Copy Markdown
Contributor

@alex-clickhouse just let me know when you're ready to merge.

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