bigbang
bigbang

Reputation: 17

getSubTypesOf returning anonymous types defined in tests

The problem I am facing is the same as described in this github issue: getSubTypesOf returning anonymous types defined in tests

The thread seems to have ended with only a couple of responses and nothing seems to be of help on the web. Can anybody help with an elegant fix for this? Thanks in advance.

I have tried searching over SO, Github issues and other tutorials to read more about Reflections library and see if there's an option to exclude the test directory while scanning but couldn't find something.

Upvotes: -1

Views: 29

Answers (1)

bigbang
bigbang

Reputation: 17

For anybody who is looking for a not so elegant fix, this is how I have currently excluded the test directory:

final Set<Class<? extends BaseClass>> subTypes =
        new Reflections(new ConfigurationBuilder().forPackages(myPackage).filterInputsBy(new FilterBuilder().exclude("test")))
            .getSubTypesOf(BaseClass.class);

Upvotes: 1

Related Questions