public Executor(ITestExecutionSink executionSink, TestRunRequest request, RemoteTaskDepot depot, CancellationToken token) { this.request = request; this.token = token; context = new RunContext(depot, executionSink); }
public void OnTestSessionTimeoutShouldGetCalledWhenExecutionCrossedTestSessionTimeout() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <TestSessionTimeout>1000</TestSessionTimeout> </RunConfiguration> </RunSettings>"; var testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1, true, settingsXml); var executionManager = new Mock <IProxyExecutionManager>(); var testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object); ManualResetEvent onTestSessionTimeoutCalled = new ManualResetEvent(true); onTestSessionTimeoutCalled.Reset(); executionManager.Setup(o => o.Abort()).Callback(() => onTestSessionTimeoutCalled.Set()); testRunRequest.ExecuteAsync(); onTestSessionTimeoutCalled.WaitOne(20 * 1000); executionManager.Verify(o => o.Abort(), Times.Once); }
public async Task <(TestRunResponse, bool isNew, ServiceError)> ReplaceTestRun( int sessionId, int testRunId, TestRunRequest testRunRequest) { var testRun = await _dbService.Query <TestRun>(testRunId).Include(r => r.ExtraData).FirstOrDefaultAsync(); bool isNew; if (testRun == null) { isNew = true; testRun = testRunRequest.ToDataModel(sessionId); _dbService.Add(testRun); } else { isNew = false; if (testRun.TestRunSessionId != sessionId) { return(null, false, ServiceError.NotFound($"TestRun with Id of {testRunId} does not belong to session {sessionId}.")); } testRunRequest.Update(testRun); } await _dbService.SaveChangesAsync(); return(testRun.ToResponse(), isNew, null); }
public async Task <TestRunResponse> InsertTestRunAsync(int sessionId, TestRunRequest testRunRequest) { var testRun = testRunRequest.ToDataModel(sessionId); await _dbService.InsertAsync(testRun); return(testRun.ToResponse()); }
public void TestInit() { testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1); executionManager = new Mock <IProxyExecutionManager>(); testRunRequest = new TestRunRequest(testRunCriteria, executionManager.Object); }
public Task Execute(TestRunRequest message) { var executor = CreateTestExecutor(); executor.RunTests(message, new TestDiscoverySink(broker), new TestExecutionSink(broker)); return(Task.CompletedTask); }
public static void Update(this TestRunRequest testRunRequest, TestRun testRun) { testRun.TestCaseId = testRunRequest.TestCaseId; testRun.State = testRunRequest.State; testRun.StartTime = testRunRequest.StartTime; testRun.FinishTime = testRunRequest.FinishTime; testRun.Outcome = testRunRequest.Outcome; testRun.ErrorMessage = testRunRequest.ErrorMessage; testRun.ExtraData.UpdateFrom(testRunRequest.ExtraData); }
public TestRunRequestTests() { testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1); executionManager = new Mock <IProxyExecutionManager>(); this.mockRequestData = new Mock <IRequestData>(); this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object); }
public static TestRun ToDataModel(this TestRunRequest r, int?testRunSessionId = null) { return(new TestRun() { TestRunSessionId = testRunSessionId ?? 0, TestCaseId = r.TestCaseId, State = r.State, StartTime = r.StartTime, FinishTime = r.FinishTime, Outcome = r.Outcome, ErrorMessage = r.ErrorMessage, ExtraData = r.ExtraData.ToDataModel() }); }
public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfTestRunIsNotInProgress() { var mockCustomLauncher = new Mock <ITestHostLauncher>(); testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); executionManager = new Mock <IProxyExecutionManager>(); testRunRequest = new TestRunRequest(testRunCriteria, executionManager.Object); var testProcessStartInfo = new TestProcessStartInfo(); testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny <TestProcessStartInfo>()), Times.Never); }
public async Task <IActionResult> ReplaceTestRun(int sessionId, int id, TestRunRequest testRunRequest) { var(testRunResponse, isNew, error) = await _service.ReplaceTestRun(sessionId, id, testRunRequest); if (!error.IsSuccessful()) { return(error.ToActionResult()); } if (isNew) { return(CreatedAt(testRunResponse)); } else { return(Ok(testRunResponse)); } }
public void LaunchProcessWithDebuggerAttachedShouldCallCustomLauncherIfLauncherIsDebugAndRunInProgress() { var mockCustomLauncher = new Mock <ITestHostLauncher>(); testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); executionManager = new Mock <IProxyExecutionManager>(); testRunRequest = new TestRunRequest(testRunCriteria, executionManager.Object); testRunRequest.ExecuteAsync(); var testProcessStartInfo = new TestProcessStartInfo(); mockCustomLauncher.Setup(ml => ml.IsDebug).Returns(true); testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); mockCustomLauncher.Verify(ml => ml.LaunchTestHost(testProcessStartInfo), Times.Once); }
public void OnTestSessionTimeoutShouldNotGetCalledWhenTestSessionTimeoutIsZero() { string settingsXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <RunConfiguration> <TestSessionTimeout>0</TestSessionTimeout> </RunConfiguration> </RunSettings>"; var testRunCriteria = new TestRunCriteria(new List <string> { "foo" }, 1, true, settingsXml); var executionManager = new Mock <IProxyExecutionManager>(); var testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object); executionManager.Setup(o => o.StartTestRun(It.IsAny <TestRunCriteria>(), It.IsAny <ITestRunEventsHandler>())).Callback(() => System.Threading.Thread.Sleep(5 * 1000)); testRunRequest.ExecuteAsync(); executionManager.Verify(o => o.Abort(), Times.Never); }
/// <summary> /// Runs the test in given assembly against the provided source assembly. /// </summary> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="TestResult"/>. /// </returns> public TestResult RunTests(TestRunRequest request) { Uri uri = new Uri(request.TestAssembly.CodeBase); this.localDirectory = Path.GetDirectoryName(uri.LocalPath); this.engine = TestEngineActivator.CreateInstance(null, InternalTraceLevel.Off); var settings = new Dictionary <string, object>(); var runner = new DefaultTestAssemblyRunner(new DefaultTestAssemblyBuilder()); runner.Load(request.TestAssembly, settings); // Convert our own framework XmlNode to a TestEngineResult var package = new TestPackage(this.GetLocalPath(uri.AbsolutePath)); this.engineResult = TestEngineResult.MakeTestRunResult( package, DateTime.Now, new TestEngineResult( runner.Run(TestListener.NULL, NUnit.Framework.Internal.TestFilter.Empty).ToXml(true).OuterXml)); return(this.SummaryTransformTest()); }
public async Task <IActionResult> InsertTestRun(int sessionId, TestRunRequest testRunRequest) { var testRun = await _service.InsertTestRunAsync(sessionId, testRunRequest); return(CreatedAt(testRun)); }
public Task RunTests(TestRunRequest request) => Task.CompletedTask;
public async Task <TestRunResponse> InsertTestRunAsync(int sessionId, TestRunRequest testRunRequest) { return(await SendAsync <TestRunResponse>(HttpMethod.Post, $"sessions/{sessionId}/runs", testRunRequest)); }