Search Unity

Feedback Mock UnityEngine Utilities functions

Discussion in 'Scripting' started by Galilleos, May 3, 2021.

  1. Galilleos

    Galilleos

    Joined:
    Sep 13, 2020
    Posts:
    1
    Hello,
    I am writing a component to handle the abstract part of my game.
    I would like to have it as much independent as I can from UnityEngine code (in order to do unit testing and CI on it). Still, I want to use some utilities functions in it (for example Debug.log or JsonUtility).
    As it seems not possible to import and start UnityEngine in VisualStudio, I am thinking of mocking those functions to do my build and tests.
    Is it a good idea? Is there already some opensource projects doing it?

    Example of what I am doing in my testing code to replace the Debug.Log:
    Code (CSharp):
    1. namespace UnityEngine
    2. {
    3.     class Debug
    4.     {
    5.         static public void Log(String toLog)
    6.         {
    7.             Console.WriteLine(toLog);
    8.         }
    9.     }
    10. }
    Thanks
    Julien
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    No.

    But I'm sure somebody will tell you it is.

    I've just never bothered with it.

    Test what you need in place.

    Use as little or as much of the Unity engine as you like.

    Get your game done, get it out into customer's hands.

    Everything else is ... less than useful.