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

Should we replace most of the PowerMocking with singleton patterns? #380

Open
Salmela opened this issue Jul 9, 2016 · 2 comments
Open
Labels

Comments

@Salmela
Copy link
Contributor

Salmela commented Jul 9, 2016

We could replace most of the static classes with singletons like this:
https://gist.github.com/Salmela/a9dcedfeb055249b72110e2022ba00c9

Another way to get rid of staticness of the TmcUtil and the SettingsIo would be to add
getters for them in CliContext. Which could be replaced with Mockito spying or giving them
in the constructor.

Third way to fix the static classes could be dependency injection library like Guice,
but I don't have a clue how to integrate it easily into our project.

@Salmela Salmela changed the title Should we replace most of the PowerMocking with singleton pattern? Should we replace most of the PowerMocking with singleton patterns? Jul 9, 2016
@jclc
Copy link
Contributor

jclc commented Jul 10, 2016

Is it really a good idea to replace static classes with instances? I thought we were moving away from this when I refactored SettingsIo and CourseInfoIo.

@Salmela
Copy link
Contributor Author

Salmela commented Jul 10, 2016

The unit testing of static classes is bit of a pain. But we have now tests for nearly all of the code so It would take lot of time to change the unit tests. And I think there is more important stuff to be done here.

Also I unit tested some non-static util methods and their testing wasn't as easy as I would have hoped.

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

No branches or pull requests

2 participants