Skip to content

test: [Sample Tests 2] Share the system-test envelope matchers - #6267

Draft
runningcode wants to merge 1 commit into
no/mock-sentry-serverfrom
no/shared-envelope-matchers
Draft

runningcode wants to merge 1 commit into
no/mock-sentry-serverfrom
no/shared-envelope-matchers

Conversation

@runningcode

@runningcode runningcode commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Moves the envelope matchers from TestHelper (sentry-system-test-support) into sentry-test-support, as extension functions:

  • Item accessors: SentryEnvelope.event(), transaction(), logs(), metrics(), profileChunk().
  • Matchers: for example SentryTransaction.hasSpanWithOp, SentryLogEvents.hasLogWithAttribute, SentryEvent.hasFlag. Like before, they return false and print what they looked at, so tests can pick one envelope out of many.

TestHelper keeps its public methods and delegates to the shared code. That way the sample tests don't change, and only one copy of each matcher exists while they are being moved.

Cleanups along the way:

  • Two pairs of near-identical TestHelper methods each map onto one matcher with optional parameters:
    • doesTransactionHaveOp and doesTransactionHave → hasOp
    • doesTransactionContainSpanWithOp and doesTransactionHaveSpanWith → hasSpanWithOp
  • The unused doesTransactionContainSpanWithDescription is dropped.
  • TestHelper.logObject used PrintWriter(System.out).use {}, which closes System.out and silenced every line after the first mismatch. It now flushes instead.

💡 Motivation and Context

The in-module integration tests in the following PRs need these matchers. They can't depend on sentry-system-test-support, because that module brings in:

  • Apollo 4;
  • okhttp 4, which clashes with the okhttp 5 modules;
  • hardcoded ports.

💚 How did you test it?

  • EnvelopeMatchersTest sends real transactions, events, logs and metrics through MockSentryServer and checks positive and negative cases for each matcher.
  • Ran the log4j2 sample's system test through the runner. It really executed (no FROM-CACHE) and passed, which confirms the TestHelper delegation.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

  • The next PRs use the matchers to move the logback sample's test and to test the OTel agent.
  • Once the last sample test is gone, TestHelper and sentry-system-test-support are deleted.

#skip-changelog

In-module integration tests need the same envelope matchers the sample
system tests use. TestHelper now delegates to the shared copies, so the
sample tests keep working unchanged while they are moved.

Mismatch diagnostics now flush System.out instead of closing it, which
silenced all output after the first mismatch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/shared-envelope-matchers branch from 47c6edc to cf186ed Compare October 15, 2026 14:23
@runningcode
runningcode force-pushed the no/mock-sentry-server branch from ba3ad5c to 254fe63 Compare October 15, 2026 14:23
@sentry

sentry Bot commented Oct 15, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

This was referenced Oct 20, 2026

This branch has not been deployed

No deployments
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.

1 participant