- Home /
Is there a limit to Test Runner play mode test duration?
I'm having an issue with the test runner. My play mode tests only run for a total of 30 seconds. Example: I will be in a for loop for (var i = 0; i <100; i++)
with a WaitForSeconds(1);
This test should run for 100 seconds, however the test ends after 30 seconds. no matter what parameter i put in the for loop (assuming it will run for over 30 seconds) it continuously ends at 6 seconds.
Does anyone know what's going and how to fix it?
Edit: I am using coroutines with the [Unity Test] attribute:
The code is attatched. link text
Answer by HaraldNielsen · Nov 13, 2017 at 06:40 PM
Hi, So [UnityTest] actually starts a coroutine executing that method.
For the Test stopping, try to set the TimeOut to something high. It could be it picked up the default one.
I completely forgot about the Timeout Attribute. It worked perfectly. Thank you.
Answer by bhavinbhai2707 · Nov 13, 2017 at 04:05 PM
waitForSeconds is not a method so it cannot be called directly!! The Correct way for using waitForSeconds is to use it in Couroutines.
//User Defined Function
private IEnumerator CoroutineFunction()
{
//Statements
yield return new WaitForSeconds(1f);
}
Correct way for Doing Your Problem is
void Start () {
StartCoroutine(CoroutineFunction());
}
// Update is called once per frame
private IEnumerator CoroutineFunction()
{
for (int i = 0; i < 100; i++)
{
Debug.Log(i);
yield return new WaitForSeconds(1f);
}
}
I should have clarified, I am using a co-routine. I am also using yield return new WaitForSeconds(1f);
The issue persists
Can you show us the full code you are using?? Because the above code i gave seems to be working fine!!
I just added it to the original post. $$anonymous$$y other coroutines work fine, The issue seems to stem from the Test Runner as far as I can tell
Your answer
Follow this Question
Related Questions
How to implement mandatory cleanup for the Unity PlayMode tests? 1 Answer
TestRunner playmode IPrebuildSetup test doesn't run 1 Answer
Unity Test Runner doesn't cleanup previous test results 1 Answer
How to load a scene in PlayMode tests 2 Answers
Unity Test Tools - Integration Test for existing scenes 1 Answer