Search Unity

TestPlayerBuildModifier not working

Discussion in 'Testing & Automation' started by Maeslezo, Mar 11, 2020.

  1. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    332
    Hello,

    I have been following the conference QA your code, from Richard Fine @superpig

    I am having problems with TestPlayerBuildModifier attribute. It seems it is not been called

    The thing is that the way of use is quite straightforward, so I don't know if I am missing something.

    My script
    Code (CSharp):
    1. using System.Linq;
    2. using UnityEditor;
    3. using UnityEditor.TestTools;
    4. using UnityEngine;
    5.  
    6. [assembly:TestPlayerBuildModifier(typeof(IncludeTestSceneInBuild))]
    7. public class IncludeTestSceneInBuild : ITestPlayerBuildModifier
    8. {
    9.     private const string SCENE_NAME = "Assets/Tests/Performance/cool_down.unity";
    10.  
    11.     public BuildPlayerOptions ModifyOptions(BuildPlayerOptions playerOptions)
    12.     {
    13.         Debug.Log("Modify options");
    14.         if (!playerOptions.scenes.Contains(SCENE_NAME))
    15.         {
    16.             playerOptions.scenes = playerOptions.scenes.Append(SCENE_NAME).ToArray();
    17.         }
    18.  
    19.         return playerOptions;
    20.     }
    21. }
    22.  
    Code (CSharp):
    1.         [UnityTest]
    2.         public IEnumerator LoadSceneTest()
    3.         {
    4.             // Use the Assert class to test conditions.
    5.             // Use yield to skip a frame.
    6.             yield return SceneManager.LoadSceneAsync("cool_down", LoadSceneMode.Additive);
    7.             Assert.Pass();
    8.         }
    The assembly where the ITestPlayerBuildModifier script is localetd
    upload_2020-3-11_10-39-50.png

    My result:
    upload_2020-3-11_10-40-4.png

    Additional Information:

    Unity 2019.3.0f6
    Test Framework 1.1.11

    Thank you
     
  2. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    332
    This problem has been fixed in Test Framework V1.1.13

    Thank you
     
    Warnecke likes this.