< Summary

Class:GDX.Developer.ConsoleCommands.BuildVerificationTestConsoleCommand
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleCommands/BuildVerificationTestConsoleCommand.cs
Covered lines:3
Uncovered lines:50
Coverable lines:53
Total lines:131
Line coverage:5.6% (3 of 53)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:5
Method coverage:20% (1 of 5)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Evaluate(...)0%90900%
GetKeyword()0%110100%
GetHelpUsage()0%2100%
GetHelpMessage()0%2100%
GetInstance(...)0%20400%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleCommands/BuildVerificationTestConsoleCommand.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using System.Collections.Generic;
 7using System.IO;
 8using System.Threading.Tasks;
 9using GDX.Developer.Reports;
 10using GDX.Developer.Reports.BuildVerification;
 11using UnityEngine;
 12using UnityEngine.SceneManagement;
 13
 14namespace GDX.Developer.ConsoleCommands
 15{
 16#if UNITY_2022_2_OR_NEWER
 17
 18    public class BuildVerificationTestConsoleCommand : ConsoleCommandBase
 19    {
 20        TestScene[] m_Scenes;
 21        int m_ScenesCount;
 22
 23        State m_State;
 24        Task m_TestRunner;
 25
 26        /// <inheritdoc />
 27        public override bool Evaluate(float deltaTime)
 028        {
 029            switch (m_State)
 30            {
 31                case State.Init:
 032                    BuildVerificationReport.Reset();
 033                    m_State = State.Run;
 034                    return false;
 35                case State.Run:
 036                    m_TestRunner = TestRunner.Execute(m_Scenes);
 037                    m_State = State.Wait;
 038                    return false;
 39
 40                case State.Wait:
 41
 042                    if (m_TestRunner == null)
 043                    {
 044                        Debug.LogError("The test runner was unable to run.");
 045                        return true;
 46                    }
 47
 48                    // Test runner thinks everything is done
 049                    if (m_TestRunner.IsCompleted)
 050                    {
 051                        m_State = State.Output;
 052                        return false;
 53                    }
 54
 55
 056                    return false;
 57
 58                case State.Output:
 59
 060                    string outputPath = Path.GetFullPath(Path.Combine(Platform.GetOutputFolder(),
 61                        $"BVT-{DateTime.Now.ToString(Localization.FilenameTimestampFormat)}.xml"));
 62
 063                    string result = BuildVerificationReport.OutputReport(outputPath);
 64
 065                    Debug.Log(File.Exists(outputPath)
 66                            ? $"Build checks ({result}) written to {outputPath}."
 67                            : $"Unable to write file to {outputPath}.");
 068                    return true;
 69            }
 70
 071            return true;
 072        }
 73
 74        /// <inheritdoc />
 75        public override string GetKeyword()
 776        {
 777            return "bvt";
 778        }
 79
 80        /// <inheritdoc />
 81        public override string GetHelpUsage()
 082        {
 083            return "bvt <SceneName, ...>";
 084        }
 85
 86        /// <inheritdoc />
 87        public override string GetHelpMessage()
 088        {
 089            return "Loads a specific scene and attempts to run any automated tests associated with that process.";
 090        }
 91
 92        /// <inheritdoc />
 93        public override ConsoleCommandBase GetInstance(string context)
 094        {
 095            BuildVerificationTestConsoleCommand command =
 96                new BuildVerificationTestConsoleCommand { m_State = State.Init };
 97
 098            string[] scenes = context.Split(',');
 099            int sceneCount = scenes.Length;
 0100            List<TestScene> validScenes = new List<TestScene>(sceneCount);
 0101            for (int i = 0; i < sceneCount; i++)
 0102            {
 0103                Scene s = SceneManager.GetSceneByName(scenes[i]);
 0104                if (s.IsValid())
 0105                {
 0106                    validScenes.Add(new TestScene(s.buildIndex));
 0107                }
 0108            }
 109
 0110            command.m_Scenes = validScenes.ToArray();
 0111            command.m_ScenesCount = command.m_Scenes.Length;
 112
 0113            if (command.m_ScenesCount > 0)
 0114            {
 0115                return command;
 116            }
 117
 0118            Debug.LogWarning($"No valid scenes were able to be extracted from '{context}'.");
 0119            return null;
 0120        }
 121
 122        enum State
 123        {
 124            Init,
 125            Run,
 126            Wait,
 127            Output
 128        }
 129    }
 130#endif // UNITY_2022_2_OR_NEWER
 131}

Coverage by test methods







Methods/Properties

Evaluate(System.Single)
GetKeyword()
GetHelpUsage()
GetHelpMessage()
GetInstance(System.String)