Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to generate getters #31

Closed
bhchandra opened this issue Feb 14, 2018 · 3 comments
Closed

Option to generate getters #31

bhchandra opened this issue Feb 14, 2018 · 3 comments

Comments

@bhchandra
Copy link

I am unable to mock generated Conf class for testing with Mockito even after enabling mocking final classes/methods in Mockito.

This is failing with Mockito.when(...).thenReturn(...);
I am guessing this is because Mockito can mock only method calls.

@carueda
Copy link
Owner

carueda commented Feb 15, 2018

Could you elaborate a bit? I'm not referring to the Mockito part per se, but the need for mocking the configuration in the first place. Is it perhaps that there's not direct way to instantiate the config classes (other than via a Typesafe Config object)?

@bhchandra
Copy link
Author

Sorry for the late reply.

Is it perhaps that there's not direct way to instantiate the config classes (other than via a Typesafe Config object)?

I am not exactly sure what you mean.

The problem is that the class under test is tightly coupled with the Conf object, but requires only single configuration parameter (bad desgin). So the simple thing required for testing is Mockito.when(conf.getA()).thenReturn(x), which is not possible.
To test the class, I now need to create Typesafe Config object with all the required configuration parameters. This is good if I am doing an integration test but seems like extra work for unit testing.

Thank you for bringing type safety and auto completion to configuration.

@carueda carueda changed the title Any configuration option to generate getters for the inner classes. ? Option to generate getters Feb 17, 2018
@carueda
Copy link
Owner

carueda commented Feb 17, 2018

@bhchandra I've just implemented your suggestion. New release 0.9.3. The new option is --java:getters. Hope it covers what you need. Thanks for using tscfg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants