-
Notifications
You must be signed in to change notification settings - Fork 2k
initial setup of unity testing framework #88
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
base: main
Are you sure you want to change the base?
Conversation
Note the one thing that does concern me with this PR is found within the UnityOpenProject1.asmdef assembly definition file Any libraries referenced in any scripts have to be included as references. So for example: using I feel like that does create a level of complexity that will be new to a lot of unity developers and possibly that perfect combination of unwelcome, annoying, frustrating and, stupid. I don't know if there is a solution to that outside of updated documentation. Does anyone know of a way to auto-add referenced assemblies via ASMDEF? |
AFAIK, there is no way to auto-reference every package with asmdef. |
Hmmm ... Interesting. Thanks for the insight. That'd be a pretty reasonable workaround, except the ASMDEF on the main project is required in order to be able to reference its code from within the context of the tests. So for example, you can't actually create a "Protagonist" controller to run tests on it unless you can reference the assembly. |
Update: I've put together a bit of reorganization.
Still outstanding:
Ideally having a runnable unit test framework in place when things start coming in LIKE the finite state machine will make it easier to stay on top of testing and quality from the start of the project. |
Per a forum comment, this PR adds 4 external dependencies each is listed here with a link to the licenses included
These license files have been extracted or downloaded as appropriate and included in the Assets/Plugins/UnitTesting.Mock folder |
Just leaving some comments here instead of the forum post. Disclaimer: I have no clue about Unity but I'm somewhat good at unit/integration/functional testing and TDD/BDD/ATDD methodologies.
Regards, |
Hi , I have an example of testing input using the new input system. https://github.com/kgc00/BeatEmUpSandbox/blob/combat_v2/Assets/Scripts/TestSandbox/PlayMode/KeyLoggerTests.cs Maybe I'll take a look tomorrow and see if there is a quick fix Alternatively you could just not test the input, assume it works since it is unity core, and test the event systems / downstream code that uses it. EDIT: Hi, i was able to get some Inputreader unit tests in. They're in this PR #144 but feel free to use my approach here as well, Alex. |
Do you have a forum thread linked to this PR? https://forum.unity.com/threads/what-about-unit-testing.981069/
What will this PR bring to the project for everyone?
Setting up unit tests is a non trivial task within unity. Specifically creating a working Assembly Definition File requires an understanding of DLL references and increases project complexity.
The advantage once the tests are further fleshed out are two fold:
Why are these changes necessary?
Within the discussion on the thread the is some debate with respect to the value of testing and when to start. Based on my experience having tests in place from the early stages allows things to be developed in a testable way from the start. Adding testing later in the project lifecycle is MUCH more challenging.
How did you implement them?
In this instance I have created a proof of concept which will prove that tests can run within the context of the project.
I have stopped short of including a test of any of the monobehaviors because I'd like to get feedback on the decision to put the ASMDEF file in the root of the project versus having one for scripts and one for the input folder.
Additionally as a next-step goal I'd like to go through the effort of creating a MOCK and demonstrating a MOCK based test. On that front I'd also like to see some feedback on how the wider team would like to see the inclusion of NUGET packages handled. I know how I'd do it on my own, but there may be global preferences about that sort of thing.
I expect this PR will need more feedback - before being accepted - but it is a foundational piece to get the ball rolling.