emilybache / GildedRose-Refactoring-Kata

Starting code for the GildedRose Refactoring Kata in many programming languages.
https://youtu.be/Mt4XpGxigT4
MIT License
3.68k stars 5.13k forks source link

Questions about implementing Unity (Game Engine) #561

Open nateonline opened 1 month ago

nateonline commented 1 month ago

Hi @emilybache, I'm working on adapting the kata for Unity game developers. Here's some questions I have:

  1. Unity doesn't have a way to compile down to a command line program, so I'm not sure I'll be able to integrate it with TextTest. Would it be suitable/appropriate to write some code to compare a custom log with the text file instead? Or does this make Unity a bad candidate for addition into this repo?

  2. As I was reviewing the C# ApprovalTest.ThirtyDays.verified.txt file, I noticed that I hadn't implemented the conjured item feature yet, but my output was identical. The existing file seems to have output that doesn't include the conjured item feature (ex: day 1 mana cake quality = 6, and day 2 it's 5 instead of 4). Is this a mistake or am I missing something?

  3. Do you have any other concerns or words of advice as I try to implement a Unity version of this kata?

Let me know, thanks!

emilybache commented 1 month ago

Happy to hear that you're planning to do this!

  1. If there is no CLI in Unity then just don't worry about it, no need to add this. If there is another approval testing framework for Unity then you could include a starter test for that but if there isn't then just the one ordinary unit test is sufficient.

  2. This is not a mistake, it's the way approval testing works. The approved file represents the current approved functionality. Once the conjured item functionality is implemented, you're expected to approve a new version and update it.

  3. I know very little about Unity but we already have about 50 language versions so I'm happy to see another one!

One of my goals with this repo (alongside helping people learn to do refactoring properly) is to point out the advantages of approval testing for legacy code. If Unity doesn't have an explicit test framework for this style of testing yet then I don't want you to try to invent one just for this kata.

nateonline commented 1 month ago

Thanks for the reply! Unity does have a custom version of NUnit for C# that it uses, as well as a graphical interface for running the tests from the Unity editor. It's actually used by a lot fewer beginners than I would hope, which is most of my motivation for building Unity language support in this repo. I'll try to be very informative in my readme on how to setup and run these tests.