TestLauncherFactory.cs
2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner;
namespace UnityEditor.TestTools.TestRunner.Api
{
internal class TestLauncherFactory
{
internal TestLauncherBase GetLauncher(ExecutionSettings executionSettings)
{
if (executionSettings.filter.testMode == TestMode.EditMode)
{
return GetEditModeLauncher(executionSettings.filter);
}
else
{
var settings = PlaymodeTestsControllerSettings.CreateRunnerSettings(executionSettings.filter.ToTestRunnerFilter());
return GetPlayModeLauncher(settings, executionSettings);
}
}
static TestLauncherBase GetEditModeLauncher(Filter filter)
{
return GetEditModeLauncherForProvidedAssemblies(filter);
}
static TestLauncherBase GetPlayModeLauncher(PlaymodeTestsControllerSettings settings, ExecutionSettings executionSettings)
{
if (executionSettings.targetPlatform != null)
{
return GetPlayerLauncher(settings, executionSettings.targetPlatform.Value, executionSettings.overloadTestRunSettings);
}
if (PlayerSettings.runPlayModeTestAsEditModeTest)
{
return GetEditModeLauncherForProvidedAssemblies(executionSettings.filter, TestPlatform.PlayMode);
}
return GetPlayModeLauncher(settings);
}
static TestLauncherBase GetEditModeLauncherForProvidedAssemblies(Filter filter, TestPlatform testPlatform = TestPlatform.EditMode)
{
return new EditModeLauncher(filter.ToTestRunnerFilter(), testPlatform);
}
static TestLauncherBase GetPlayModeLauncher(PlaymodeTestsControllerSettings settings)
{
return new PlaymodeLauncher(settings);
}
static TestLauncherBase GetPlayerLauncher(PlaymodeTestsControllerSettings settings, BuildTarget targetPlatform, ITestRunSettings overloadTestRunSettings)
{
return new PlayerLauncher(settings, targetPlatform, overloadTestRunSettings);
}
}
}