Exemplo n.º 1
0
        public static void OnModelInitializationHandler(UnityModelAndLifetime modelAndLifetime)
        {
            ourLogger.Verbose("AdviseUnitTestLaunch");
            var modelValue         = modelAndLifetime.Model;
            var connectionLifetime = modelAndLifetime.Lifetime;

            modelValue.GetCompilationResult.Set(_ => !EditorUtility.scriptCompilationFailed);

#if !UNITY_5_6 // before 5.6 this file is not included at all
            CompiledAssembliesTracker.Init(modelAndLifetime);
#endif

            modelValue.UnitTestLaunch.Advise(connectionLifetime, launch =>
            {
                new TestEventsSender(launch);
            });

            modelValue.RunUnitTestLaunch.Set(rdVoid =>
            {
                if (!modelValue.UnitTestLaunch.HasValue())
                {
                    return(false);
                }
                var testLauncher = new UnityEditorTestLauncher(modelValue.UnitTestLaunch.Value, connectionLifetime);
                return(testLauncher.TryLaunchUnitTests());
            });
        }
Exemplo n.º 2
0
        public static void OnModelInitializationHandler(UnityModelAndLifetime modelAndLifetime)
        {
            ourLogger.Verbose("AdviseUnitTestLaunch");
            var modelValue         = modelAndLifetime.Model;
            var connectionLifetime = modelAndLifetime.Lifetime;

            modelValue.GetCompilationResult.Set(_ => !EditorUtility.scriptCompilationFailed);

            modelValue.UnitTestLaunch.Advise(connectionLifetime, launch =>
            {
                var collector = TestEventsCollector.Instance;
                ourLogger.Verbose("TestEventsCollectorInstance: " + collector.GetInstanceID() + " DelayedEvents.Count:" + collector.DelayedEvents.Count);
                new TestEventsSender(collector, launch);
            });

            modelValue.RunUnitTestLaunch.Advise(connectionLifetime, () =>
            {
                if (!modelValue.UnitTestLaunch.HasValue())
                {
                    return;
                }
                var testLauncher = new UnityEditorTestLauncher(modelValue.UnitTestLaunch.Value);
                testLauncher.TryLaunchUnitTests();
            });
        }