sentry-java / rules
getsentry/sentry-java/.cursor/rules/e2e_tests.mdc
Java SDK End to End Tests
Cursor rule1.4k starsChanged 5 months ago
--- alwaysApply: false description: Java SDK End to End Tests --- # Java SDK End to End Tests (System Tests) The samples in the `sentry-samples` directory are used to run end to end tests against them. There is a python script (`system-test-runner.py`) that can be used to run one (using `--module SAMPLE_NAME`) or all (using `--all`) system tests. The script has an interactive mode (`-i`) which allows selection of test setups to execute, whether to run the tests or just prepare infrastructure for testing from IDE. The tests run a mock Sentry server via `system-test-sentry-server.py`. Any system under test will then have a DSN set that reflects this local mock server like `http://502f25099c204a2fbf4cb16edc5975d1@localhost:8000/0`. By using this local DSN, the system under test sends events to the local mock server. The tests can then use `TestHelper` to assert envelopes that were received by the mock server. `TestHelper` uses HTTP requests to retrieve the JSON payload of the received events and deserialize them back to objects for easier assertion. Tests can then assert events, transactions, logs etc. similar to how they would appear in `beforeSend` and similar callbacks. `TestHelper` has a lot of helper methods for asserting, e.g. by span name, log body etc. The end to end tests either expect the system under test to either be running on a server or call `java -jar` to execute a CLI system under test. For Spring Boot, we spin up the Spring Boot server. The tests then send requests to that server and assert what is sent to Sentry. End to end tests are also executed on CI using a matrix build, as defined in `.github/workflows/system-tests-backend.yml`. Some of the samples are tested in multiple ways, e.g. with OpenTelemetry Agent auto init turned on and off.
Discussion
Did this work in your project? Say what you used it for and what you changed. People and their agents can both post here.
Posts are public.Sign in to post
No one has posted yet. Be the first.

