protected UnityTestAssemblyRunner LoadTests(ITestFilter filter)
        {
            var editorLoadedTestAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());
            var assembliesWithTests = editorLoadedTestAssemblyProvider.GetAssembliesGroupedByType(TestPlatform.PlayMode).Select(x => x.Assembly.GetName().Name).ToList();

            var nUnitTestAssemblyRunner = new UnityTestAssemblyRunner(new UnityTestAssemblyBuilder(), null);
            var assemblyProvider        = new PlayerTestAssemblyProvider(new AssemblyLoadProxy(), assembliesWithTests);

            nUnitTestAssemblyRunner.Load(assemblyProvider.GetUserAssemblies().Select(a => a.Assembly).ToArray(), UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(TestPlatform.PlayMode));
            return(nUnitTestAssemblyRunner);
        }
示例#2
0
        private void InitRunner()
        {
            //We give the EditMode platform here so we dont suddenly create Playmode work items in the test Runner.
            m_Runner = (UnityTestAssemblyRunnerFactory ?? new UnityTestAssemblyRunnerFactory()).Create(TestPlatform.EditMode, new EditmodeWorkItemFactory());
            var testAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());
            var assemblies           = testAssemblyProvider.GetAssembliesGroupedByType(m_TestPlatform).Select(x => x.Assembly).ToArray();
            var loadedTests          = m_Runner.Load(assemblies,
                                                     UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(m_TestPlatform));

            loadedTests.ParseForNameDuplicates();
            hideFlags |= HideFlags.DontSave;
            EnumerableSetUpTearDownCommand.ActivePcHelper = new EditModePcHelper();
            OuterUnityTestActionCommand.ActivePcHelper    = new EditModePcHelper();
        }
        protected Scene CreateBootstrapScene(string sceneName, Action <PlaymodeTestsController> runnerSetup)
        {
            var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
            var go    = new GameObject(PlaymodeTestsController.kPlaymodeTestControllerName);

            var editorLoadedTestAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());

            var runner = go.AddComponent <PlaymodeTestsController>();

            runnerSetup(runner);
            runner.settings.bootstrapScene = sceneName;
            runner.AssembliesWithTests     = editorLoadedTestAssemblyProvider.GetAssembliesGroupedByType(TestPlatform.PlayMode).Select(x => x.Assembly.GetName().Name).ToList();

            EditorSceneManager.MarkSceneDirty(scene);
            AssetDatabase.SaveAssets();
            EditorSceneManager.SaveScene(scene, sceneName, false);

            return(scene);
        }
示例#4
0
 public TestListProvider(EditorLoadedTestAssemblyProvider assemblyProvider, UnityTestAssemblyBuilder assemblyBuilder)
 {
     m_AssemblyProvider = assemblyProvider;
     m_AssemblyBuilder  = assemblyBuilder;
 }