- Home /
TestRunner playmode timeout (?)
Hi all,
Question:
Does the TestRunner feature (Unity 5.6) have a timeout setting somewhere? And if so, then where can I deactivate it?
Context:
Using the TestRunner to run tests in PlayMode (coroutine-alike) my test so far always terminate (pass) prematurely after about 30 seconds.
(I need my test runs to run considerably longer in order to test complex gameplay scenarios.) 
Code:
Here is a snippet that reliably produces the phenomenon for me:
 using UnityEngine;
 using UnityEngine.TestTools;
 using NUnit.Framework;
 using System.Collections;
 public class TestingTest 
 {
     // A UnityTest behaves like a coroutine in PlayMode
     // and allows you to yield null to skip a frame in EditMode
     [UnityTest]
     public IEnumerator TestingTestWithEnumeratorPasses() 
     {
         float timeIntervalReport = 1;
         float timeReportLast = 0;
         float durationDesired = 40;
         
         float timeStart = Time.time;
         Debug.Log("timeStart " + timeStart);
         
         while(Time.time < timeStart + durationDesired){
             if(timeReportLast + timeIntervalReport < Time.time){
                 Debug.Log("time passed " + (Time.time - timeStart));
                 timeReportLast = Time.time;
             }
             yield return null;
         }        
         Debug.Log("test complete");
     }
 }
Thanks for your consideration.
Answer by HardlyDifficultLLC · Jun 29, 2017 at 09:03 PM
Dear @SantaKlaus,
We hit the same and found that you can change the timeout by adding another attribute. e.g.
  [UnityTest]
  [Timeout(100000000)]
  public IEnumerator Test2() 
 {
    ...
 }
I don't know how to say no timeout, but big numbers work well :)
hth,
HardlyDifficult
That is almost 30 hours.
This value is in milliseconds, so if you want 5 $$anonymous$$utes you'd go with something like 300000.
Answer by SantaKlaus · Jun 30, 2017 at 06:24 AM
Thanks HardlyDifficult,
Yeah, that attribute seems to do the trick. I wonder why Unity didnt mention it in their docs. Probably because not officially supported.
BR,
Your answer
 
 
             Follow this Question
Related Questions
Concurrency and editor scripts and the play mode 1 Answer
Play Mode Unit Tests prevent game build succeeding,PlayMode Unit Tests prevent my game from building 1 Answer
Automated testing webgl mouse events not working 1 Answer
PlayMode Test - Loading Scenes 1 Answer
Can we create playmode tests outside of the main build assembly? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                