Beispiel #1
0
    static void RunAllTestsIOS()
    {
        try {
            AltUnityTesterEditor.InitEditorConfiguration();
            UnityEngine.Debug.Log("Started running test");
            System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
            System.Reflection.Assembly   assembly   = assemblies.FirstOrDefault(assemblyName => assemblyName.GetName().Name.Equals("Assembly-CSharp-Editor"));

            var testSuite2 = (NUnit.Framework.Internal.TestSuite) new NUnit.Framework.Api.DefaultTestAssemblyBuilder().Build(assembly, new System.Collections.Generic.Dictionary <string, object>());

            NUnit.Framework.Internal.Filters.OrFilter filter = new NUnit.Framework.Internal.Filters.OrFilter();
            foreach (var test in testSuite2.Tests)
            {
                foreach (var t in test.Tests)
                {
                    UnityEngine.Debug.Log(t.FullName);
                    filter.Add(new NUnit.Framework.Internal.Filters.FullNameFilter(t.FullName));
                }
            }

            NUnit.Framework.Interfaces.ITestListener listener = new TestRunListener(null);
            var testAssemblyRunner = new NUnit.Framework.Api.NUnitTestAssemblyRunner(new NUnit.Framework.Api.DefaultTestAssemblyBuilder());
            testAssemblyRunner.Load(assembly, new System.Collections.Generic.Dictionary <string, object>());
            var result = testAssemblyRunner.Run(listener, filter);
            if (result.FailCount > 0)
            {
                UnityEditor.EditorApplication.Exit(1);
            }
        } catch (System.Exception e) {
            UnityEngine.UnityEngine.Debug.LogError(e);
            UnityEditor.EditorApplication.Exit(1);
        }
    }
Beispiel #2
0
    public static void RunTests(TestRunMode testMode)
    {
        UnityEngine.Debug.Log("Started running test");
        System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
        System.Reflection.Assembly   assembly   = assemblies.FirstOrDefault(assemblyName => assemblyName.GetName().Name.Equals("Assembly-CSharp-Editor"));

        var filters = AddTestToBeRun(testMode);

        NUnit.Framework.Interfaces.ITestListener listener = new TestRunListener(CallRunDelegate);
        var testAssemblyRunner = new NUnit.Framework.Api.NUnitTestAssemblyRunner(new NUnit.Framework.Api.DefaultTestAssemblyBuilder());

        testAssemblyRunner.Load(assembly, new System.Collections.Generic.Dictionary <string, object>());
        progress = 0;
        total    = filters.Filters.Count;
        System.Threading.Thread runTestThread = new System.Threading.Thread(() => {
            var result = testAssemblyRunner.Run(listener, filters);
            SetTestStatus(result);
            AltUnityTesterEditor.isTestRunResultAvailable = true;
            AltUnityTesterEditor.selectedTest             = -1;
        });

        runTestThread.Start();
        if (AltUnityTesterEditor.EditorConfiguration.platform != Platform.Editor)
        {
            float previousProgres = progress - 1;
            while (runTestThread.IsAlive)
            {
                if (previousProgres == progress)
                {
                    continue;
                }
                UnityEditor.EditorUtility.DisplayProgressBar(progress == total ? "This may take a few seconds" : _testName,
                                                             progress + "/" + total, progress / total);
                previousProgres = progress;
            }
        }

        runTestThread.Join();
        if (AltUnityTesterEditor.EditorConfiguration.platform != Platform.Editor)
        {
            AltUnityTesterEditor.needsRepaiting = true;
            UnityEditor.EditorUtility.ClearProgressBar();
        }
    }
Beispiel #3
0
 public string EnqueueTestPlan(string testPlanId, IDictionary <string, string> args, TestRunListener listener)
 {
     return(tim.EnqueueTestPlan(testPlanId, args));
 }
Beispiel #4
0
 public string EnqueueTestPlan(string testPlanId, IDictionary<string, string> args, TestRunListener listener)
 {
     return tim.EnqueueTestPlan(testPlanId, args);
 }