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); } }
public static void BuildAndroidFromUI(bool autoRun = false) { try { AltUnityTesterEditor.InitEditorConfiguration(); InitBuildSetup(UnityEditor.BuildTargetGroup.Android); UnityEngine.Debug.Log("Starting Android build..." + UnityEditor.PlayerSettings.productName + " : " + UnityEditor.PlayerSettings.bundleVersion); UnityEditor.BuildPlayerOptions buildPlayerOptions = new UnityEditor.BuildPlayerOptions(); buildPlayerOptions.locationPathName = AltUnityTesterEditor.EditorConfiguration.OutputPathName + ".apk"; buildPlayerOptions.scenes = GetScenesForBuild(); buildPlayerOptions.target = UnityEditor.BuildTarget.Android; if (autoRun) { buildPlayerOptions.options = UnityEditor.BuildOptions.Development | UnityEditor.BuildOptions.AutoRunPlayer; } else { buildPlayerOptions.options = UnityEditor.BuildOptions.Development; } var results = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions); #if UNITY_2017 if (results.Equals("")) { UnityEngine.Debug.Log("No Build Errors"); } else { UnityEngine.Debug.LogError("Build Error!"); } #else if (results.summary.totalErrors == 0) { UnityEngine.Debug.Log("No Build Errors"); } else { UnityEngine.Debug.LogError("Build Error! " + results.steps + "\n Result: " + results.summary.result + "\n Stripping info: " + results.strippingInfo); } #endif UnityEngine.Debug.Log("Finished. " + UnityEditor.PlayerSettings.productName + " : " + UnityEditor.PlayerSettings.bundleVersion); } catch (System.Exception e) { UnityEngine.Debug.LogError(e); } finally { built = true; ResetBuildSetup(UnityEditor.BuildTargetGroup.Android); } }
private static string[] GetScenesForBuild() { if (AltUnityTesterEditor.EditorConfiguration.Scenes.Count == 0) { AltUnityTesterEditor.AddAllScenes(); AltUnityTesterEditor.SelectAllScenes(); } List <string> sceneList = new List <string>(); foreach (var scene in AltUnityTesterEditor.EditorConfiguration.Scenes) { if (scene.ToBeBuilt) { sceneList.Add(scene.Path); } } InsertAltUnityInTheFirstScene(); return(sceneList.ToArray()); }
public static void ShowWindow() { //Show existing window instance. If one doesn't exist, make one. _window = (AltUnityTesterEditor)GetWindow(typeof(AltUnityTesterEditor)); _window.Show(); }