spring-projects / spring-projects/spring-modulith

[UnitTest] Check for events that should not arrive

Open
#1,357 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

This issue is based on this discussion.

I want to create a test that checks that an event was NOT published. The usecase I try to replicate is that the publisher can be configured to temporarily ignore specific event types (e.g. because the target system is not available). So I am looking for something like this:

scenario.stimulate(() -> collector.poll())
            .andWaitAtMost(Duration.ofSeconds(5))
            .andWaitForEventOfType(NewJobEvent.class)
            .not().toArrive();
//or
scenario.stimulate(() -> collector.poll())
            .andWaitAtMost(Duration.ofSeconds(5))
            .andWaitForEventOfType(NewJobEvent.class)
            .notToArrive();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked discussion, then inspect the scenario API around stimulate, andWaitAtMost, andWaitForEventOfType, and the collector.poll() example. Trace existing event-arrival tests and determine how a NewJobEvent absence should be asserted; done means a test covers the negative case for an ignored event type and the API clearly reports success or failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.