Пример #1
0
        private readonly IEnumerable <string> _appArguments; // Arguments that will be passed to the iOS application

        public AppRunner(
            IMlaunchProcessManager processManager,
            IHardwareDeviceLoader hardwareDeviceLoader,
            ISimulatorLoader simulatorLoader,
            ICrashSnapshotReporterFactory snapshotReporterFactory,
            ICaptureLogFactory captureLogFactory,
            IDeviceLogCapturerFactory deviceLogCapturerFactory,
            IExitCodeDetector exitCodeDetector,
            IFileBackedLog mainLog,
            ILogs logs,
            IHelpers helpers,
            IEnumerable <string> appArguments,
            Action <string>?logCallback = null)
            : base(hardwareDeviceLoader, mainLog, logCallback)
        {
            _processManager           = processManager ?? throw new ArgumentNullException(nameof(processManager));
            _simulatorLoader          = simulatorLoader ?? throw new ArgumentNullException(nameof(simulatorLoader));
            _snapshotReporterFactory  = snapshotReporterFactory ?? throw new ArgumentNullException(nameof(snapshotReporterFactory));
            _captureLogFactory        = captureLogFactory ?? throw new ArgumentNullException(nameof(captureLogFactory));
            _deviceLogCapturerFactory = deviceLogCapturerFactory ?? throw new ArgumentNullException(nameof(deviceLogCapturerFactory));
            _exitCodeDetector         = exitCodeDetector ?? throw new ArgumentNullException(nameof(exitCodeDetector));
            _logs         = logs ?? throw new ArgumentNullException(nameof(logs));
            _helpers      = helpers ?? throw new ArgumentNullException(nameof(helpers));
            _appArguments = appArguments;
        }
Пример #2
0
 public AppRunner(IProcessManager processManager,
     IHardwareDeviceLoader hardwareDeviceLoader,
     ISimulatorLoader simulatorLoader,
     ISimpleListenerFactory simpleListenerFactory,
     ICrashSnapshotReporterFactory snapshotReporterFactory,
     ICaptureLogFactory captureLogFactory,
     IDeviceLogCapturerFactory deviceLogCapturerFactory,
     ITestReporterFactory reporterFactory,
     ILog mainLog,
     ILogs logs,
     IHelpers helpers,
     bool useXmlOutput)
 {
     _processManager = processManager ?? throw new ArgumentNullException(nameof(processManager));
     _hardwareDeviceLoader = hardwareDeviceLoader ?? throw new ArgumentNullException(nameof(hardwareDeviceLoader));
     _simulatorLoader = simulatorLoader ?? throw new ArgumentNullException(nameof(simulatorLoader));
     _listenerFactory = simpleListenerFactory ?? throw new ArgumentNullException(nameof(simpleListenerFactory));
     _snapshotReporterFactory = snapshotReporterFactory ?? throw new ArgumentNullException(nameof(snapshotReporterFactory));
     _captureLogFactory = captureLogFactory ?? throw new ArgumentNullException(nameof(captureLogFactory));
     _deviceLogCapturerFactory = deviceLogCapturerFactory ?? throw new ArgumentNullException(nameof(deviceLogCapturerFactory));
     _testReporterFactory = reporterFactory ?? throw new ArgumentNullException(nameof(_testReporterFactory));
     _mainLog = mainLog ?? throw new ArgumentNullException(nameof(mainLog));
     _logs = logs ?? throw new ArgumentNullException(nameof(logs));
     _helpers = helpers ?? throw new ArgumentNullException(nameof(helpers));
     _useXmlOutput = useXmlOutput;
 }
Пример #3
0
 public AppRunner(IMLaunchProcessManager processManager,
                  IHardwareDeviceLoader hardwareDeviceLoader,
                  ISimulatorLoader simulatorLoader,
                  ISimpleListenerFactory simpleListenerFactory,
                  ICrashSnapshotReporterFactory snapshotReporterFactory,
                  ICaptureLogFactory captureLogFactory,
                  IDeviceLogCapturerFactory deviceLogCapturerFactory,
                  ITestReporterFactory reporterFactory,
                  IFileBackedLog mainLog,
                  ILogs logs,
                  IHelpers helpers,
                  bool useXmlOutput,
                  Action <string>?logCallback = null)
 {
     _processManager           = processManager ?? throw new ArgumentNullException(nameof(processManager));
     _hardwareDeviceLoader     = hardwareDeviceLoader ?? throw new ArgumentNullException(nameof(hardwareDeviceLoader));
     _simulatorLoader          = simulatorLoader ?? throw new ArgumentNullException(nameof(simulatorLoader));
     _listenerFactory          = simpleListenerFactory ?? throw new ArgumentNullException(nameof(simpleListenerFactory));
     _snapshotReporterFactory  = snapshotReporterFactory ?? throw new ArgumentNullException(nameof(snapshotReporterFactory));
     _captureLogFactory        = captureLogFactory ?? throw new ArgumentNullException(nameof(captureLogFactory));
     _deviceLogCapturerFactory = deviceLogCapturerFactory ?? throw new ArgumentNullException(nameof(deviceLogCapturerFactory));
     _testReporterFactory      = reporterFactory ?? throw new ArgumentNullException(nameof(_testReporterFactory));
     _logs         = logs ?? throw new ArgumentNullException(nameof(logs));
     _helpers      = helpers ?? throw new ArgumentNullException(nameof(helpers));
     _useXmlOutput = useXmlOutput;
     if (logCallback == null)
     {
         _mainLog = mainLog ?? throw new ArgumentNullException(nameof(mainLog));
     }
     else
     {
         // create using the main as the default log
         _mainLog = Log.CreateReadableAggregatedLog(mainLog, new CallbackLog(logCallback));
     }
 }
Пример #4
0
        private readonly IEnumerable <string> _appArguments; // Arguments that will be passed to the iOS application

        public AppTester(
            IMlaunchProcessManager processManager,
            IHardwareDeviceLoader hardwareDeviceLoader,
            ISimulatorLoader simulatorLoader,
            ISimpleListenerFactory simpleListenerFactory,
            ICrashSnapshotReporterFactory snapshotReporterFactory,
            ICaptureLogFactory captureLogFactory,
            IDeviceLogCapturerFactory deviceLogCapturerFactory,
            ITestReporterFactory reporterFactory,
            IResultParser resultParser,
            IFileBackedLog mainLog,
            ILogs logs,
            IHelpers helpers,
            IEnumerable <string> appArguments,
            Action <string>?logCallback = null)
            : base(processManager, hardwareDeviceLoader, captureLogFactory, logs, mainLog, logCallback)
        {
            _processManager           = processManager ?? throw new ArgumentNullException(nameof(processManager));
            _simulatorLoader          = simulatorLoader ?? throw new ArgumentNullException(nameof(simulatorLoader));
            _listenerFactory          = simpleListenerFactory ?? throw new ArgumentNullException(nameof(simpleListenerFactory));
            _snapshotReporterFactory  = snapshotReporterFactory ?? throw new ArgumentNullException(nameof(snapshotReporterFactory));
            _captureLogFactory        = captureLogFactory ?? throw new ArgumentNullException(nameof(captureLogFactory));
            _deviceLogCapturerFactory = deviceLogCapturerFactory ?? throw new ArgumentNullException(nameof(deviceLogCapturerFactory));
            _testReporterFactory      = reporterFactory ?? throw new ArgumentNullException(nameof(_testReporterFactory));
            _resultParser             = resultParser ?? throw new ArgumentNullException(nameof(resultParser));
            _mainLog      = mainLog ?? throw new ArgumentNullException(nameof(mainLog));
            _logs         = logs ?? throw new ArgumentNullException(nameof(logs));
            _helpers      = helpers ?? throw new ArgumentNullException(nameof(helpers));
            _appArguments = appArguments;
        }
Пример #5
0
 public MacTestTasksEnumerable(Jenkins jenkins,
                               IMlaunchProcessManager processManager,
                               ICrashSnapshotReporterFactory crashReportSnapshotFactory,
                               ITestVariationsFactory testVariationsFactory)
 {
     this.jenkins                    = jenkins ?? throw new ArgumentNullException(nameof(jenkins));
     this.processManager             = processManager ?? throw new ArgumentNullException(nameof(processManager));
     this.crashReportSnapshotFactory = crashReportSnapshotFactory ?? throw new ArgumentNullException(nameof(crashReportSnapshotFactory));
     this.testVariationsFactory      = testVariationsFactory ?? throw new ArgumentNullException(nameof(testVariationsFactory));
 }
Пример #6
0
 public AppRunnerFactory(
     IMlaunchProcessManager processManager,
     ICrashSnapshotReporterFactory snapshotReporterFactory,
     ICaptureLogFactory captureLogFactory,
     IDeviceLogCapturerFactory deviceLogCapturerFactory,
     IHelpers helpers)
 {
     _processManager           = processManager ?? throw new ArgumentNullException(nameof(processManager));
     _snapshotReporterFactory  = snapshotReporterFactory ?? throw new ArgumentNullException(nameof(snapshotReporterFactory));
     _captureLogFactory        = captureLogFactory ?? throw new ArgumentNullException(nameof(captureLogFactory));
     _deviceLogCapturerFactory = deviceLogCapturerFactory ?? throw new ArgumentNullException(nameof(deviceLogCapturerFactory));
     _helpers = helpers ?? throw new ArgumentNullException(nameof(helpers));
 }
Пример #7
0
        public AppRunnerTests()
        {
            _mainLog = new Mock <IFileBackedLog>();

            _processManager = new Mock <IMlaunchProcessManager>();
            _processManager.SetReturnsDefault(Task.FromResult(new ProcessExecutionResult()
            {
                ExitCode = 0
            }));

            _hardwareDeviceLoader = new Mock <IHardwareDeviceLoader>();
            _hardwareDeviceLoader
            .Setup(x => x.FindDevice(RunMode.iOS, _mainLog.Object, false, false))
            .ReturnsAsync(s_mockDevice);

            _simulatorLoader  = new Mock <ISimulatorLoader>();
            _snapshotReporter = new Mock <ICrashSnapshotReporter>();

            _logs = new Mock <ILogs>();
            _logs.SetupGet(x => x.Directory).Returns(Path.Combine(s_outputPath, "logs"));

            var factory2 = new Mock <ICrashSnapshotReporterFactory>();

            factory2.SetReturnsDefault(_snapshotReporter.Object);
            _snapshotReporterFactory = factory2.Object;

            _exitCodeDetector = new Mock <IExitCodeDetector>();

            _mockSimulator = new Mock <ISimulatorDevice>();
            _mockSimulator.SetupGet(x => x.Name).Returns(SimulatorDeviceName);
            _mockSimulator.SetupGet(x => x.UDID).Returns("58F21118E4D34FD69EAB7860BB9B38A0");
            _mockSimulator.SetupGet(x => x.LogPath).Returns(_simulatorLogPath);
            _mockSimulator.SetupGet(x => x.SystemLog).Returns(Path.Combine(_simulatorLogPath, "system.log"));

            _helpers = new Mock <IHelpers>();
            _helpers
            .Setup(x => x.GetTerminalName(It.IsAny <int>()))
            .Returns("tty1");
            _helpers
            .Setup(x => x.GenerateStableGuid(It.IsAny <string>()))
            .Returns(Guid.NewGuid());
            _helpers
            .SetupGet(x => x.Timestamp)
            .Returns("mocked_timestamp");
            _helpers
            .Setup(x => x.GetLocalIpAddresses())
            .Returns(new[] { IPAddress.Loopback, IPAddress.IPv6Loopback });

            Directory.CreateDirectory(s_outputPath);
        }
Пример #8
0
        public void SetUp()
        {
            logs = new Mock <ILogs> ();
            logs.SetupGet(x => x.Directory).Returns(Path.Combine(outputPath, "logs"));

            processManager   = new Mock <IMlaunchProcessManager> ();
            simulators       = new Mock <ISimulatorLoader> ();
            devices          = new Mock <IHardwareDeviceLoader> ();
            simpleListener   = new Mock <ISimpleListener> ();
            snapshotReporter = new Mock <ICrashSnapshotReporter> ();

            var mock1 = new Mock <ISimulatorLoaderFactory> ();

            mock1.Setup(m => m.CreateLoader()).Returns(simulators.Object);
            simulatorsFactory = mock1.Object;

            var mock2 = new Mock <IDeviceLoaderFactory> ();

            mock2.Setup(m => m.CreateLoader()).Returns(devices.Object);
            devicesFactory = mock2.Object;

            var mock3 = new Mock <ISimpleListenerFactory> ();

            mock3
            .Setup(m => m.Create(It.IsAny <RunMode> (), It.IsAny <ILog> (), It.IsAny <IFileBackedLog> (), It.IsAny <bool> (), It.IsAny <bool> (), It.IsAny <bool> ()))
            .Returns((ListenerTransport.Tcp, simpleListener.Object, "listener-temp-file"));
            listenerFactory = mock3.Object;
            simpleListener.Setup(x => x.InitializeAndGetPort()).Returns(listenerPort);

            var mock4 = new Mock <ICrashSnapshotReporterFactory> ();

            mock4.Setup(m => m.Create(It.IsAny <ILog> (), It.IsAny <ILogs> (), It.IsAny <bool> (), It.IsAny <string> ())).Returns(snapshotReporter.Object);
            snapshotReporterFactory = mock4.Object;

            var mock5 = new Mock <IAppBundleInformationParser> ();

            mock5
            .Setup(x => x.ParseFromProject(It.IsAny <string> (), It.IsAny <TestTarget> (), It.IsAny <string> ()))
            .ReturnsAsync(new AppBundleInformation(appName, appName, appPath, appPath, true, null));

            appBundleInformationParser = mock5.Object;

            mainLog = new Mock <IFileBackedLog> ();

            Directory.CreateDirectory(appPath);
        }
Пример #9
0
 public MacExecuteTask(Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager, ICrashSnapshotReporterFactory crashReportSnapshotFactory)
     : base(jenkins, build_task, processManager)
 {
     this.CrashReportSnapshotFactory = crashReportSnapshotFactory ?? throw new ArgumentNullException(nameof(crashReportSnapshotFactory));
 }
Пример #10
0
 public RunXtroTask(Jenkins jenkins, BuildToolTask build_task, IMlaunchProcessManager processManager, ICrashSnapshotReporterFactory crashReportSnapshotFactory)
     : base(jenkins, build_task, processManager, crashReportSnapshotFactory)
 {
 }
Пример #11
0
        public AppRunnerTests()
        {
            _mainLog = new Mock <ILog>();

            _processManager = new Mock <IProcessManager>();
            _processManager.SetReturnsDefault(Task.FromResult(new ProcessExecutionResult()
            {
                ExitCode = 0
            }));

            _hardwareDeviceLoader = new Mock <IHardwareDeviceLoader>();
            _hardwareDeviceLoader
            .Setup(x => x.FindDevice(RunMode.iOS, _mainLog.Object, false, false))
            .ReturnsAsync(s_mockDevice);

            _simulatorLoader = new Mock <ISimulatorLoader>();
            _simulatorLoader
            .Setup(x => x.LoadDevices(It.IsAny <ILog>(), false, false, false))
            .Returns(Task.CompletedTask);

            _listener = new Mock <ISimpleListener>();
            _listener
            .SetupGet(x => x.ConnectedTask)
            .Returns(Task.CompletedTask);

            _snapshotReporter = new Mock <ICrashSnapshotReporter>();

            _testReporter = new Mock <ITestReporter>();
            _testReporter
            .Setup(r => r.Success)
            .Returns(true);
            _testReporter
            .Setup(r => r.ParseResult())
            .ReturnsAsync((TestExecutingResult.Succeeded, "Tests run: 1194 Passed: 1191 Inconclusive: 0 Failed: 0 Ignored: 0"));
            _testReporter
            .Setup(x => x.CollectSimulatorResult(It.IsAny <Task <ProcessExecutionResult> >()))
            .Returns(Task.CompletedTask);

            _logs = new Mock <ILogs>();
            _logs.SetupGet(x => x.Directory).Returns(Path.Combine(s_outputPath, "logs"));

            _tunnelBore = new Mock <ITunnelBore>();
            _tunnelBore.Setup(t => t.Close(It.IsAny <string>()));

            _listenerFactory = new Mock <ISimpleListenerFactory>();
            _listenerFactory.SetReturnsDefault((ListenerTransport.Tcp, _listener.Object, "listener-temp-file"));
            _listenerFactory.Setup(f => f.TunnelBore).Returns(_tunnelBore.Object);
            _listener.SetupGet(x => x.Port).Returns(1020);

            var factory2 = new Mock <ICrashSnapshotReporterFactory>();

            factory2.SetReturnsDefault(_snapshotReporter.Object);
            _snapshotReporterFactory = factory2.Object;

            var factory3 = new Mock <ITestReporterFactory>();

            factory3.SetReturnsDefault(_testReporter.Object);
            _testReporterFactory = factory3.Object;

            _helpers = new Mock <IHelpers>();
            _helpers
            .Setup(x => x.GetTerminalName(It.IsAny <int>()))
            .Returns("tty1");
            _helpers
            .Setup(x => x.GenerateStableGuid(It.IsAny <string>()))
            .Returns(Guid.NewGuid());
            _helpers
            .SetupGet(x => x.Timestamp)
            .Returns("mocked_timestamp");

            Directory.CreateDirectory(s_outputPath);
        }
Пример #12
0
        public AppTesterTests()
        {
            _mainLog = new Mock <IFileBackedLog>();

            _processManager = new Mock <IMlaunchProcessManager>();
            _processManager.SetReturnsDefault(Task.FromResult(new ProcessExecutionResult()
            {
                ExitCode = 0
            }));

            _hardwareDeviceLoader = new Mock <IHardwareDeviceLoader>();
            _hardwareDeviceLoader
            .Setup(x => x.FindDevice(RunMode.iOS, _mainLog.Object, false, false))
            .ReturnsAsync(s_mockDevice);

            _simulatorLoader = new Mock <ISimulatorLoader>();

            _mockSimulator = new Mock <ISimulatorDevice>();
            _mockSimulator.SetupGet(x => x.Name).Returns(SimulatorDeviceName);
            _mockSimulator.SetupGet(x => x.UDID).Returns("58F21118E4D34FD69EAB7860BB9B38A0");
            _mockSimulator.SetupGet(x => x.LogPath).Returns(_simulatorLogPath);
            _mockSimulator.SetupGet(x => x.SystemLog).Returns(Path.Combine(_simulatorLogPath, "system.log"));

            _listener = new Mock <ISimpleListener>();
            _listener
            .SetupGet(x => x.ConnectedTask)
            .Returns(Task.FromResult(true));

            _snapshotReporter = new Mock <ICrashSnapshotReporter>();

            _testReporter = new Mock <ITestReporter>();
            _testReporter
            .Setup(r => r.Success)
            .Returns(true);
            _testReporter
            .Setup(r => r.ParseResult())
            .ReturnsAsync((TestExecutingResult.Succeeded, "Tests run: 1194 Passed: 1191 Inconclusive: 0 Failed: 0 Ignored: 0"));
            _testReporter
            .Setup(x => x.CollectSimulatorResult(It.IsAny <ProcessExecutionResult>()))
            .Returns(Task.CompletedTask);

            _logs = new Mock <ILogs>();
            _logs.SetupGet(x => x.Directory).Returns(Path.Combine(s_outputPath, "logs"));

            _tunnelBore = new Mock <ITunnelBore>();
            _tunnelBore.Setup(t => t.Close(It.IsAny <string>()));

            _listenerFactory = new Mock <ISimpleListenerFactory>();
            _listenerFactory.SetReturnsDefault((ListenerTransport.Tcp, _listener.Object, "listener-temp-file"));
            _listenerFactory.Setup(f => f.TunnelBore).Returns(_tunnelBore.Object);
            _listener.Setup(x => x.InitializeAndGetPort()).Returns(Port);

            var factory2 = new Mock <ICrashSnapshotReporterFactory>();

            factory2.SetReturnsDefault(_snapshotReporter.Object);
            _snapshotReporterFactory = factory2.Object;

            var factory3 = new Mock <ITestReporterFactory>();

            factory3.SetReturnsDefault(_testReporter.Object);
            _testReporterFactory = factory3.Object;

            _helpers = new Mock <IHelpers>();
            _helpers
            .Setup(x => x.GetTerminalName(It.IsAny <int>()))
            .Returns("tty1");
            _helpers
            .Setup(x => x.GenerateStableGuid(It.IsAny <string>()))
            .Returns(Guid.NewGuid());
            _helpers
            .SetupGet(x => x.Timestamp)
            .Returns("mocked_timestamp");
            _helpers
            .Setup(x => x.GetLocalIpAddresses())
            .Returns(new[] { IPAddress.Loopback, IPAddress.IPv6Loopback });

            Directory.CreateDirectory(s_outputPath);
        }
Пример #13
0
 public RunXtroTask(BuildToolTask build_task, IProcessManager processManager, ICrashSnapshotReporterFactory crashReportSnapshotFactory)
     : base(build_task, processManager, crashReportSnapshotFactory)
 {
 }