Search Unity

Resolved Test Runner - Test not failing

Discussion in 'Testing & Automation' started by TaleOf4Gamers, Oct 11, 2017.

  1. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    I created a simple test just to try out Tests as I have never really done it before.
    I made it fail on purpose just to make sure everything works as expected. Nope, the icon stays as the passed icon just with an error in the console.

    Here is my test:
    Code (CSharp):
    1. using NUnit.Framework;
    2. using OpenTrivia_Sharp;
    3. using OpenTrivia_Sharp.OpenTrivia;
    4.  
    5. public class TriviaTests
    6. {
    7.     public class API
    8.     {
    9.         [Test]
    10.         public async void CanGetTrivia()
    11.         {
    12.             OpenTriviaClient client = new OpenTriviaClient();
    13.             var result = await client.CreateQuiz(new QuizParams() {
    14.                     questions = 2,
    15.             });
    16.      
    17.             Assert.AreEqual(result.questions.Count, 1);
    18.         }
    19.     }
    20. }
    21.  
    It simply tries to retrieve 2 questions from an API (Which works great) but no matter what it wont fail within the test runner. Is this a bug or am I missing something. May it could be because it is an async method?



    Thanks.
     
    Last edited: Oct 11, 2017
  2. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Fixed. Yep its because it was asynchronous.