public void RegisterTestSessionFinish(string sessionId, DateTime endedAt) { var testRun = RunContext.GetCurrentTestRun(); var testSession = _sessionIdToSession[sessionId]; if (testRun != null && testSession != null) { Log($"({testRun.Id}, {testSession.Id}) Registering test session update..."); var request = new UpdateTestSessionRequest { EndedAt = endedAt.ToUniversalTime() }; _apiClient.RegisterTestSessionUpdate(testRun.Id, testSession.Id, request); _sessionIdToSession.Remove(sessionId); _threadSessionIds.Value.Remove(sessionId); Log($"({testRun.Id}, {testSession.Id}) Test session update was registered successfully."); } }
private void Link(string sessionId, long zebrunnerTestId) { var testRun = RunContext.GetCurrentTestRun(); var testSession = _sessionIdToSession[sessionId]; if (testRun != null && testSession != null) { if (testSession.TestIds.Add(zebrunnerTestId)) { Log($"({testRun.Id}) Linking test with id {zebrunnerTestId} to session {sessionId}."); var request = new UpdateTestSessionRequest { TestIds = new HashSet <long> { zebrunnerTestId } }; _apiClient.RegisterTestSessionUpdate(testRun.Id, testSession.Id, request); Log($"({testRun.Id}) Session {sessionId} was linked to test {zebrunnerTestId} successfully."); } } }
public SaveTestSessionResponse RegisterTestSessionUpdate(long testRunId, long testSessionId, UpdateTestSessionRequest requestBody) { var request = new RestRequest(Reporting($"/v1/test-runs/{testRunId}/test-sessions/{testSessionId}"), DataFormat.Json); request.AddJsonBody(requestBody); var response = _restClient.Put <SaveTestSessionResponse>(request); if (response.StatusCode == HttpStatusCode.OK) { return(response.Data); } throw new Exception($"Could not register update of test session. Response body is {response.Content}"); }