SMOG Matcher Generator

Compatible with: IntelliJ IDEA Android Studio
12.07.2015
578

Generates a companion matcher class for a selected Java class based on the SMOG library extension to Hamcrest.

The SMOG library supports property matching on object graphs. For more details, see the project page at GitHub.

This plugin is also hosted at GitHub.

Download plugin

Recent change notes

0.5

Updated to support generating interface-only matchers. Interface-only matchers can be used with the SMOG-Javassist library, which generates the matcher implementation at runtime, significantly cutting down on the amount of boiler-plate code maintained within a project.

SMOG-Javassist is hosted at GitHub.

0.4

Updated to fix incompatibility with IDEA 14.0

0.3

Correction to the 'since-build' metadata. Plugin requires IntelliJ IDEA version 13.1 or later.

0.2

This version is compatible with smog-core library version 1.0 available from maven central.

A number of improvements have been made in this version, including:

  • A new code generator is used that manages imports much better and avoids the need for unnecessary fully qualified names in the code.
  • Matchers generated for abstract classes are no longer abstract, allowing them to be instantiated and used for matching any concrete subclass of the matched class.
  • The generator now extensively supports generic properties and generic classes.
  • Generated matchers get reformatted to use project formatting settings.
  • Generated matcher classes are now annotated with @Matches.

0.1

First release.

General usage instructions

This plugin adds a Generate Matcher menu option to the Code menu in IntelliJ IDEA.

It generates matcher classes that can be used as Hamcrest matchers.

The generated class has a dependency on the supporting SMOG library, hosted at https://github.com/mistraltechnologies/smog and available from
Maven Central.

The menu option is enabled when a Java class is selected. After selecting the menu option, a dialog is provided to specify parameters relating to how the new matcher will be generated. Confirming the dialog causes the new class to be generated. If the class already exists, you are given the option to overwrite the existing class or abort.