-
Notifications
You must be signed in to change notification settings - Fork 344
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
Unit testing and static object issues #35
Comments
I am aware of benefits of unit testing. But there are many singletons in the project, and migrating to other solutions would require a lot of work. So, my opinion is that one should focus on implementing features/fixing bugs, rather than on making tests. |
Usually implementing tests together with features have long term benefits.
Just saying.
In general nobody likes doing tests until last moment, so this have to be
experienced to understand.
Usually implementing tests post-factum is very hard task to do though;
planning upfront makes
test writing semi-automatic with proper architecture. So if you don't do it
from beginning it will be no fun
to start now.
…On Tue, Sep 24, 2019 at 3:07 AM in0finite ***@***.***> wrote:
I am aware of benefits of unit testing. But there are many singletons in
the project, and migrating to other solutions would require a lot of work.
So, my opinion is that one should focus on implementing features/fixing
bugs, rather than on making tests.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#35>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAABPUYOQ22FQVRZC2S7LMLQLFK3BANCNFSM4IZUAEPQ>
.
|
To tell you the truth, I have started working on this. The project is a promising one and fun, but also a big one. The code quality is gonna degrade without testing. It also reveals code smells which translate to bugs and a lack of inner mechanics understanding by others. |
The main problem with testing now is that all game objects and usual C# classes are interconnected via static singleton / functions. It is not practical (and maybe impossible sometimes) to test such code. The first thing to do is to find a way to decouple dependencies in order to substitute them in tests. As long as Unity creates game objects this is a tricky business but there are ways I'm trying to do / researching now. |
I wouldn't like to dissapoint you. But my opinion is that tests are not neccesary at this moment. We should focus on high priority stuff. Doing what you want requires changing core parts of the game, which can cause a lot of bugs. |
Project doesn't have any unit tests. There are numerous well-known benefits with them. Unity has NUnit integration with specific Play mode.
When I tried to implement a test I found it difficult due to global static variables and singletons couplings.
Such things prevent mocking (e.g. with Moq).
There are alternatives to singletons like Service Locator pattern (a simple Dependency Injection) which is employed in other projects. It is not perfect but in contrast to singletons it allows us to write quality tests with mocks and decouples concrete service implementations.
What do you think of gradual migration to such components structure?
The text was updated successfully, but these errors were encountered: