Learn Unit Testing for MVP/MVC Architecture in Unity

  Рет қаралды 7,435

git-amend

git-amend

Күн бұрын

Пікірлер: 77
@git-amend
@git-amend 8 ай бұрын
Hey everyone! Today is the first in a short series about MVP/MVC - starting with a topic most game devs avoid (including me - sometimes)! As this series will continue next week, please add questions/comments here or on Discord! 👍
@stevehamilton321
@stevehamilton321 8 ай бұрын
Another gem.... and I say this without having watched it yet. I look more forward to your new videos than my 5 year old looks forward to Christmas! Your effort is greatly appreciated : )
@git-amend
@git-amend 8 ай бұрын
Appreciate the vote of confidence! Cheers!
@MarushiaDark316
@MarushiaDark316 8 ай бұрын
To this day, I still don't understand the point of building unit tests, vs. just playtesting. That's likely down to my ignorance, rather than it being pointless, but I'm still searching for a satisfactory answer. It seems like you're having to write double the code for every system in your project on top of existing precautions like guard clauses, null checks, and log statements that should already give errors and messages. So yeah, I don't grok the point of this. Your video just sort of implied it was understood as good and necessary - and I hear software engineers talk about it all the time - but maybe a follow up video can go into depth as to the *why* we're even bothering in the first place. Why it's not sufficient to just play test the game a bunch or use console logs and things like that. Is this something you should do for ALL projects or just those that reach a sufficient size and complexity?
@git-amend
@git-amend 8 ай бұрын
I can talk about it a bit in the next video. Others might have similar questions. In short - I would not write tests for small projects (less than a month of development time, like a game jam) - however, the bigger your projects grows the more helpful unit testing becomes. It can become tedious to play test a bigger game every time you make changes. While writing tests does require initial effort, in the long run, they save time by quickly catching bugs and issues that might only be discovered through extensive manual testing.
@wendten2
@wendten2 8 ай бұрын
Why do you still only have 5k subs? You need to do some more marketing man, your content is very high quality and a natural step to learn more mediocre/advanced stuff, as 99% of all YT unity content is for people with less than 1year of experience I have been developing in unity for 5+ years, and your channel is one of a select few that i can still learn from
@git-amend
@git-amend 8 ай бұрын
Thanks for the kind words!
@letsgoPi
@letsgoPi 8 ай бұрын
i think game dev is a rather niche audience already and majority people when looking for game dev channels want specifically 'how do i get x to do y' videos, how do i move a character, how do i keep score, how do i make an inventory. this guys channel has some of that but also a lot of information on more abstract concepts, it's really a great resource but idk if it lends itself to getting a lot of views. regardless just need the people who are watching to continue to like and comment to help out
@mehmedcavas3069
@mehmedcavas3069 8 ай бұрын
Havent watched the video yet but I also use mvc for most of my project with zenject for dependency injection. helps me separate the game logic from visuals. good for writing unit tests, create tests scenes for individual system, make the game scaleable and I think it is way cleaner than having logic/manager objects in the scene
@git-amend
@git-amend 8 ай бұрын
Right on! I totally agree! Let me know if you have any insights to add after you watch!
@mehmedcavas3069
@mehmedcavas3069 8 ай бұрын
@@git-amend Just watched everything and I can say such a great video. Didnt know you add the TestCase attribute for parameters. For the MVC I do something different. My controllers do not now anything about views. They call events (or a bus) if something changed. The views listen to events if something changed and they can read data from models. In the past a read the data from controllers but this made it difficult to read the code
@git-amend
@git-amend 8 ай бұрын
​@@mehmedcavas3069 Thanks for the feedback! I agree with the bus method and decoupling even more, and will be touch on those ideas a bit more in the next video! Cheers!
@Offai50
@Offai50 8 ай бұрын
Another banger of a video. Do you have any recommendations on books for general architecture similar to you're videos or C#?
@git-amend
@git-amend 8 ай бұрын
I've added a pinned list in the programming section of the Discord for ya
@Offai50
@Offai50 8 ай бұрын
@@git-amend thank you so much 🙂
@letsgoPi
@letsgoPi 8 ай бұрын
hey brother i really enjoy your video style and concept choices so thanks very much for the content.
@git-amend
@git-amend 8 ай бұрын
I appreciate that!
@MarekNijaki
@MarekNijaki 8 ай бұрын
Omg... You are very skilled developer and tutor. Great video! One note from my side tho: could you consider lower pace? Like 10percent slower? I felt my brain was going to overcook at some point trying to follow with the content xd
@git-amend
@git-amend 8 ай бұрын
Thanks! I'll see what I can do.
@MarushiaDark316
@MarushiaDark316 8 ай бұрын
When I saw "MVP" in the title, my first thought was you'd be encouraging people to develop "minimum viable product" and talk about the importance of prototyping - that is, working out small isolated proofs of concept before wiring them up to the rest of your systems. I've personally developed the mneumonic: Plan -> Prototype -> Playtest -> Polish -> Publish as a general workflow guide.
@bbrainstormer2036
@bbrainstormer2036 8 ай бұрын
That is important, but not really relevant to his channel
@Forture-fm1ve
@Forture-fm1ve 8 ай бұрын
Great video. I'm facing a bit of an issue with transitioning between mini-games, and every time I add a new mini-game, there's a significant challenge. Are there any suggestions for an easy way to add mini-games and handle transitions between them without having to use Design Patterns? I've been thinking about using the Factory pattern. Can you provide some advice? Thank you very much.
@brunogattai9262
@brunogattai9262 8 ай бұрын
Great video! It would be nice if you explain how to make multiple related components work with each other while respecting the MVP/MVC model. For example: a complex combat system where the player has multiple stances and stats and can perform different combos and abilities (block, parry, etc).
@git-amend
@git-amend 8 ай бұрын
Well, I don't know how much I can pack into one video, but your suggestion has given me a few ideas.
@publiclag
@publiclag 8 ай бұрын
I've been developing with Unity for over 15 years but always found unit tests too daunting to tackle in Unity (also, all these tools didn't exist yet for most of the time). Your video inspired me to give it a new shot. I use unit tests for serverside stuff because there it makes a lot of sense to me. I didn't know Unity finally had a functional framework for testing real-time code. And this is not a topic a lot of people write/talk about. So thanks! PS: Could you add subtle breaks between sentences/paragraphs? It all goes pretty damn fast and I find myself having to pause / rewind, since I can't grasp the code while there's talking.
@git-amend
@git-amend 8 ай бұрын
Good to hear! Thanks for the feedback!
@AlCh3mi_MvP
@AlCh3mi_MvP 8 ай бұрын
I learned so much from watching this despite having implemented my own tests recently, all my looking into testing in unity taught me was syntax. Here are good practices, architectural considerations and so much more! Love your channel and videos, cant wait for the next one!
@git-amend
@git-amend 8 ай бұрын
Great to hear!
@Laumania
@Laumania 5 ай бұрын
Really interesting video! May I ask, what software are you using for these diagrams? Really like the style of it :D
@git-amend
@git-amend 5 ай бұрын
Thank you! I'm using the ExcaliDraw plugin for Obsidian - kzbin.info/www/bejne/pWHIqX5jrauDac0
@Laumania
@Laumania 5 ай бұрын
@@git-amend Have had on my todo to find a class similar to your Precondition one for a while (but you know, its never that time where you wanna make stuff like that easier :P) Anyway, now I saw yours and would use that as a starting point, however it doesn't like that obj.OrNull() method? Where is that extension method defined? :)
@git-amend
@git-amend 5 ай бұрын
@@Laumania Oh yeah, I know the feeling! I actually forgot I included that extension there, I should have included it in the gist. Regardless, it's in repo from my Extension Methods video here: github.com/adammyhre/Unity-Utils/blob/master/UnityUtils/Scripts/Extensions/GameObjectExtensions.cs
@Laumania
@Laumania 5 ай бұрын
@@git-amend Awesome! Thanks :)
@falricthesleeping9717
@falricthesleeping9717 5 ай бұрын
I still can't get behind MVC for game development, the domain that MVC and other similar patterns were born were not in game development where data and representation of stuff is so much more complex than a 2d representation of windows and some blittable types, I see the use when you want to test stuff, but I always feel this is wrong approach for achieving tests in unity.
@git-amend
@git-amend 5 ай бұрын
I don't adhere to it strictly; for me it's mostly about separation of concerns.
@techdave99
@techdave99 8 ай бұрын
Do you go into more detail about assembly definitions in another video? Or do you know of another video that does?
@git-amend
@git-amend 8 ай бұрын
I will probably make one in the future, but for now check out LlamAcademy's video here: kzbin.info/www/bejne/p6HVi3uFhdplhas
@techdave99
@techdave99 8 ай бұрын
@@git-amendThanks.
@drland963
@drland963 5 ай бұрын
Thank you for sharing; it's very helpful! Could you tell me the tool you use to design the overview? Thank you
@git-amend
@git-amend 5 ай бұрын
ExcaliDraw for Obsidian
@drland963
@drland963 5 ай бұрын
@@git-amend oh really thank you
@kr1s85
@kr1s85 8 ай бұрын
Nice video. It would be great if you could provide an architecture overview (like MVC or other models) for Netcode with game objects. I often find myself confused about who is responsible for what, especially in a Host-Client architecture.
@ezoray
@ezoray 7 ай бұрын
I have a bit of a testing dilemma I'd be grateful for some help with. I have a MonoBehaviour (ClassA) that needs to access other MonoBehaviours (ClassB and ClassC). This is no problem as I can create SerializedFields and drag those MonoBehaviours in via the inspector and all is good. The problem is when I come to testing ClassA and I want to check the calls to ClassB and ClassC are made correctly, I can't mock these classes as they are. If I implement them using an interface I can no longer drag them in via the inspector. What is the best option here? I'm looking into backing the MonoBehaviours with plain C# classes which looks good so far, but are there better alternatives?
@git-amend
@git-amend 7 ай бұрын
If you are having a tough time mocking using Interfaces, you can also mock any Class method marked as virtual. (The method you want to spy on has to be overridable) Check the documentation here: github.com/Thundernerd/Unity3D-NSubstitute?tab=readme-ov-file
@ezoray
@ezoray 7 ай бұрын
@@git-amend thanks for the quick reply, that has worked. Marking methods as virtual might just be the most painless way to go. 👍
@ezoray
@ezoray 7 ай бұрын
@@git-amendAh wait nevermind it creates a MonoBehaviour with 'new' going that route. Maybe backing with a plain C# class is the only option.
@git-amend
@git-amend 7 ай бұрын
@@ezoray Hm, yeah I didn't think of that. I'll be covering how to serialize interfaces in a future video as well, which will let you implement an interface and drag your MonoBehaviour references in Unity that way. There are some tools on the store that will do that as well.
@ezoray
@ezoray 7 ай бұрын
@@git-amend Great I'll look out for that. You're right I should look around for tools for this, I'm a bit bemused it's so easy to wire up dependencies but then so awkward to test, being able to serialize interfaces would be a godsend. Thanks for getting back to me.
@claudiogallardo6383
@claudiogallardo6383 8 ай бұрын
You are awesome, thanks for sharing! Thanks to you, Unity framework finally nakes sense to me.
@git-amend
@git-amend 8 ай бұрын
Great to hear!
@PaulRobello
@PaulRobello 8 ай бұрын
Lets Game It Out is amazing! The way he finds every little thing that can be exploited is awesome. And his mantra of "Is there a limit" for sure makes you think about sanity checking every value and action.
@git-amend
@git-amend 8 ай бұрын
Hahah yeah ain't that the truth!
@Wobling
@Wobling 8 ай бұрын
Interested in the editor functionality you have when hovering a folder and you have what looks like a create folder and create script shortcut, can you share any info on this?
@git-amend
@git-amend 8 ай бұрын
That's from this Asset here, I think it's free: assetstore.unity.com/packages/tools/utilities/project-context-actions-267429 I'm still evaluating if I like it or not.
@SuperTungbi
@SuperTungbi 8 ай бұрын
An another awesome video, advance unity, just what i looking for, thank you for your great work, keep it up 🎉
@git-amend
@git-amend 8 ай бұрын
Thanks! More to come!
@rhapsodicmajor596
@rhapsodicmajor596 2 ай бұрын
Thank you
@git-amend
@git-amend 2 ай бұрын
You're welcome!
@adriankovatana
@adriankovatana 8 ай бұрын
Exactly what I was looking for. Good stuff! Looking forward to part 2.
@git-amend
@git-amend 8 ай бұрын
Awesome, thank you!
@gonzaloasencio4503
@gonzaloasencio4503 8 ай бұрын
I was just about to start studying this, thank you very much for these tutorials
@git-amend
@git-amend 8 ай бұрын
You're very welcome!
@bbrainstormer2036
@bbrainstormer2036 8 ай бұрын
This is great. Can't wait for part 2. I love how simple you make everything seem
@git-amend
@git-amend 8 ай бұрын
Thanks!
@shunpeng5700
@shunpeng5700 8 ай бұрын
What a gem. You taught more than even my software architecture course
@git-amend
@git-amend 8 ай бұрын
Thanks! Part 2 coming next week!
@peche87_gameDev
@peche87_gameDev 8 ай бұрын
Great content as usual! Waiting for the next part :)
@git-amend
@git-amend 8 ай бұрын
Thanks! 😃 Coming soon!
@damonfedorick
@damonfedorick 8 ай бұрын
Another nice one.
@git-amend
@git-amend 8 ай бұрын
Thanks again!
@kevin41307
@kevin41307 8 ай бұрын
Can't wait for part 2!!
@git-amend
@git-amend 8 ай бұрын
👍
@abraiyan7984
@abraiyan7984 8 ай бұрын
Awesome
@git-amend
@git-amend 8 ай бұрын
Thank you!
Improve Your Unity Code with MVC/MVP Architectural Patterns
15:32
SIMPLE Tip For Better Unity Game Architecture
12:57
git-amend
Рет қаралды 33 М.
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 9 МЛН
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,9 МЛН
When to use Factory and Abstract Factory Programming Patterns
12:13
How to Implement Blackboard Architecture in Unity C#
28:57
git-amend
Рет қаралды 12 М.
UniTask: How It Replaces Coroutines, Tasks and Awaitable
24:49
Clean Code using the Strategy Pattern
12:34
git-amend
Рет қаралды 14 М.
EASY Stats and Modifiers in Unity | Broker Chain Pattern
16:05
Using Octrees and A* for Efficient Pathfinding
31:22
git-amend
Рет қаралды 6 М.
AVOID These Programmer Resume Mistakes!
15:46
git-amend
Рет қаралды 6 М.
Flyweight Factory with Unity Object Pooling
11:30
git-amend
Рет қаралды 7 М.