I'd like assert public API methods provided by an object instance.
Pseudocode sample:
Api api = Api.create();
assertThat(api)
.hasPublicMethodNamed("foo")
.doesNotHavePublicMethodNamed("bar");
Is it possible to accomplish this with ArchUnit?
I'd like assert public API methods provided by an object instance.
Pseudocode sample:
Api api = Api.create();
assertThat(api)
.hasPublicMethodNamed("foo")
.doesNotHavePublicMethodNamed("bar");
Is it possible to accomplish this with ArchUnit?
ArchUnit rules are based on classes, but you can ask your
apiinstance for its class (api.getClass()).Full example for JUnit4 (for JUnit5, just drop the
ArchUnitRunner):(Note that allowing for names
fooandfoo2in this way will not guarantee that your API has both methods. But your question didn't specify what you want to obtain. Feel free to clarify if needed.)