Skip to content

Test Support Improvements #6763

@etrandafir93

Description

@etrandafir93

I tried to use the micrometer-test module - the MeterRegistryAssert to be more specific.

is it meant to be used internally by the other micrometer modules?
Or is it meant to be publicly used by a wider audience?

If it's dedicated to public usage, I have a few questions and enhancement requests - if they make sense

1. Tests in src/java

There area few tests in src/java, like DefaultLongTaskTimerTest.

Was this done on purpose? Or could it be a mistake?

2. Specialized Assertion

MeterRegistryAssert contains a few basic assertions, such as verifying if a specific meter exists.
But we can’t really assert what the meter recorded. I was hoping for something more in line with AssertJ-style navigation, like:

MeterRegistryAssert.assertThat(meterRegistry)
  .hasTimerWithName("foo.time")
  .timer("foo.time")
    .hasCount(5)
    .hasTotalTime(...)
    // etc.

Would something like this provide any value?

3. Test Extension

In some cases (such as @SpringBootTests), I need to clear the meter registry before each test.

Would it make sense to have a dedicated mechanism for this? (maybe a junit extension or something similar to Spring Security's @WithMockUser?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions