Search Unity

Test Runner gives me "MissingReferenceException"

Discussion in 'Editor & General Support' started by ceceomer, Jun 21, 2019.

  1. ceceomer

    ceceomer

    Joined:
    Sep 1, 2014
    Posts:
    24
    Hi guys
    I created a project from scratch and added 2 classes to run under test runner. Test runner was working but editor gave me some errors i didn't understand.

    Calculator.cs
    Code (CSharp):
    1.  
    2. public class Calculator
    3. {
    4.     public double Add(double a, double b) => a + b;
    5.     public double Subtract(double a, double b) => a - b;
    6.     public double Multiply(double a, double b) => a * b;
    7.     public double Divide(double a, double b) => a / b;
    8. }
    9.  
    Send.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Send
    6. {
    7.     public string SendHello()
    8.     {
    9.        
    10.         return "Hello";
    11.     }
    12.  
    13. }
    14.  
    CalculatorTest.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using NUnit.Framework;
    4. using UnityEngine;
    5. using UnityEngine.TestTools;
    6.  
    7. namespace Tests
    8. {
    9.     public class CalculatorTest
    10.     {
    11.         [Test]
    12.         public void Add_SimpleValuesShouldCalculate()
    13.         {
    14.             double expected = 2 + 3;
    15.             double actual = new Calculator().Add(2, 3);
    16.             //Assert.Equals(expected, actual);
    17.         }
    18.         [TestCase(2,3, ExpectedResult = 5, Author = "Author")]
    19.         public double Add_SimpleValuesShouldCalculate(double a, double b)
    20.         {
    21.             double actual = new Calculator().Add(a, b);
    22.             return actual;
    23.         }
    24.  
    25.         [TestCase(2, 3, 4, ExpectedResult = 9, Author = "Author")]
    26.         public double Add_SimpleValuesShouldCalculate(double a, double b, double c)
    27.         {
    28.             double actual = new Calculator().Add(a, b);
    29.             return actual + c;
    30.         }
    31.         //[TestCase(ExpectedResult = "Hello")]
    32.         //[UnityPlatform(include = new[] { RuntimePlatform.WindowsEditor })]
    33.         //public string SayHello()
    34.         //{
    35.         //    return new Send().SendHello();
    36.         //}
    37.     }
    38. }
    39.  
     

    Attached Files: