/java-jmh-junit-utilities

A JMH utilities to be used in JUnit tests

Primary LanguageJavaApache License 2.0Apache-2.0

JMH Utils for JUnit

This micro library holds a set of JUnit utilities for usage with JMH testing framework.

Build Status Coverage Status SonarQube Tech Debt Maven Central

General use

JmhCleaner extension

JMH is kinda dirty. It leaves after himself a set of tests classes. They are placed in Maven generated sources directory and may cause a false positives in code analysis tools like SonarQube. JmhCleaner rule is designed to overcome that and remove any JMH generated classes.

Use it as a standard JUnit 5 extension. One needs to pass a test class in constructor.

Example:

@RegisterExtension
static JmhCleaner cleaner = new JmhCleaner(MyClassTest.class);

JavaAgentSkip extension

JMH is, as any performance framework, sensitive to all intrusions like running java agents. Those are coverage tools (Jacoco), debuggers, profilers and so on. To overcome that one can use JavaAgentSkip rule to automatically skip test is JAva agent is present.

Example:

@RegisterExtension
static JavaAgentSkip javaAgentSkip = JavaAgentSkip.ifPresent();

Maven

<dependency>
    <groupId>pl.wavesoftware</groupId>
    <artifactId>jmh-junit-utilities</artifactId>
    <version>2.0.0</version>
</dependency>

Contributing

Contributions are welcome!

To contribute, follow the standard git flow of:

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create new Pull Request

Even if you can't contribute code, if you have an idea for an improvement please open an issue.

Requirements

  • JDK >= 1.8

Releases

  • 2.0.0

    • Support for JDK >= 1.8
    • Support for JUnit 5
    • Dropped support for JUnit 4
  • 1.0.0

    • Support for JDK >= 1.6
    • Initial release