Search Unity

How do you do "unit tests" in Unity?

Discussion in 'Scripting' started by asperatology, Feb 8, 2016.

  1. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    I understand the concepts of "unit testing", and how important it is for software development.

    But I never been able to see code by code, line by line, how it is written. Not even a screenshot, if I can recall.

    When you are scripting, how do you do unit testing?

    For instance, I want to know if entity attacking interaction works. So I would isolate 2 game units, A and B, have one of them attack the other, and check the Console to see what the outputs are. No need for animation, or particle effects.

    Would it look like:

    Code (csharp):
    1.  
    2. GameUnit b;
    3. //...Some actions later.
    4. GameUnit a = GetComponent<GameUnit>();
    5. Debug.Log("Results: " + a.Attack(b));
    6.  
    Or something else? I would be happy to see some actual code examples, or a project package.