public void FileFinished(TestContext context, TestFileSummary testResultsSummary) { lock (sync) { nestedCallback.FileFinished(context, testResultsSummary); } }
public void FileFinished(string fileName, TestFileSummary testResultsSummary) { lock (sync) { nestedCallback.FileFinished(fileName, testResultsSummary); } }
private void FireFileFinished(ITestMethodRunnerCallback callback, string testFilesString, IEnumerable <TestFileContext> testFileContexts, JsRunnerOutput jsRunnerOutput) { var jsFileDone = jsRunnerOutput as JsFileDone; var testFileSummary = new TestFileSummary(testFilesString); testFileSummary.TimeTaken = jsFileDone.TimeTaken; foreach (var context in testFileContexts) { context.TestFileSummary.TimeTaken = jsFileDone.TimeTaken; testFileSummary.AddTestCases(context.TestFileSummary.Tests); } callback.FileFinished(testFilesString, testFileSummary); }
private TestFileSummary ReadFromStream(StreamReader stream, TestContext testContext, TestOptions testOptions, ITestMethodRunnerCallback callback, bool debugEnabled) { var referencedFile = testContext.ReferencedFiles.SingleOrDefault(x => x.IsFileUnderTest); var testIndex = 0; var summary = new TestFileSummary(testContext.InputTestFile); var codeCoverageEnabled = (!testContext.TestFileSettings.EnableCodeCoverage.HasValue && testOptions.CoverageOptions.Enabled) || (testContext.TestFileSettings.EnableCodeCoverage.HasValue && testContext.TestFileSettings.EnableCodeCoverage.Value); if (codeCoverageEnabled) { summary.CoverageObject = new CoverageData(); } string line; while ((line = stream.ReadLine()) != null) { if (debugEnabled) { Console.WriteLine(line); } var match = prefixRegex.Match(line); if (!match.Success) { continue; } var type = match.Groups["type"].Value; var json = match.Groups["json"].Value; // Only update last event timestamp if it is an important event. // Log and error could happen even though no test progress is made if (!type.Equals("Log") && !type.Equals("Error")) { lastTestEvent = DateTime.Now; } try { JsTestCase jsTestCase = null; switch (type) { case "FileStart": callback.FileStarted(testContext.InputTestFile); break; case "CoverageObject": var jsCov = jsonSerializer.Deserialize <JsCoverage>(json); summary.CoverageObject = coverageEngine.DeserializeCoverageObject(jsCov.Object, testContext); break; case "FileDone": var jsFileDone = jsonSerializer.Deserialize <JsFileDone>(json); summary.TimeTaken = jsFileDone.TimeTaken; callback.FileFinished(testContext.InputTestFile, summary); break; case "TestStart": jsTestCase = jsonSerializer.Deserialize <JsTestCase>(json); jsTestCase.TestCase.InputTestFile = testContext.InputTestFile; callback.TestStarted(jsTestCase.TestCase); break; case "TestDone": jsTestCase = jsonSerializer.Deserialize <JsTestCase>(json); jsTestCase.TestCase.InputTestFile = testContext.InputTestFile; AddLineNumber(referencedFile, testIndex, jsTestCase); testIndex++; callback.TestFinished(jsTestCase.TestCase); summary.AddTestCase(jsTestCase.TestCase); break; case "Log": var log = jsonSerializer.Deserialize <JsLog>(json); // This is an internal log message if (log.Log.Message.StartsWith(internalLogPrefix)) { ChutzpahTracer.TraceInformation("Phantom Log - {0}", log.Log.Message.Substring(internalLogPrefix.Length).Trim()); break; } log.Log.InputTestFile = testContext.InputTestFile; callback.FileLog(log.Log); summary.Logs.Add(log.Log); break; case "Error": var error = jsonSerializer.Deserialize <JsError>(json); error.Error.InputTestFile = testContext.InputTestFile; callback.FileError(error.Error); summary.Errors.Add(error.Error); ChutzpahTracer.TraceError("Eror recieved from Phantom {0}", error.Error.Message); break; } } catch (SerializationException e) { // Ignore malformed json and move on ChutzpahTracer.TraceError(e, "Recieved malformed json from Phantom in this line: '{0}'", line); } } return(summary); }
private void FireFileFinished(ITestMethodRunnerCallback callback, string testFilesString, IEnumerable<StreamingTestFileContext> testFileContexts, JsRunnerOutput jsRunnerOutput) { var jsFileDone = jsRunnerOutput as JsFileDone; var testFileSummary = new TestFileSummary(testFilesString); testFileSummary.TimeTaken = jsFileDone.TimeTaken; foreach (var context in testFileContexts) { context.TestFileSummary.TimeTaken = jsFileDone.TimeTaken; testFileSummary.AddTestCases(context.TestFileSummary.Tests); } callback.FileFinished(testFilesString, testFileSummary); }
private TestFileSummary ReadFromStream(StreamReader stream, TestContext testContext, ITestMethodRunnerCallback callback, bool debugEnabled) { var referencedFile = testContext.ReferencedJavaScriptFiles.SingleOrDefault(x => x.IsFileUnderTest); var testIndex = 0; var summary = new TestFileSummary(testContext.InputTestFile); string line; while ((line = stream.ReadLine()) != null) { if (debugEnabled) Console.WriteLine(line); var match = prefixRegex.Match(line); if (!match.Success) continue; var type = match.Groups["type"].Value; var json = match.Groups["json"].Value; // Only update last event timestamp if it is an important event. // Log and error could happen even though no test progress is made if (!type.Equals("Log") && !type.Equals("Error")) { lastTestEvent = DateTime.Now; } try { JsTestCase jsTestCase = null; switch (type) { case "FileStart": callback.FileStarted(testContext.InputTestFile); break; case "CoverageObject": var jsCov = jsonSerializer.Deserialize<JsCoverage>(json); summary.CoverageObject = coverageEngine.DeserializeCoverageObject(jsCov.Object, testContext); break; case "FileDone": var jsFileDone = jsonSerializer.Deserialize<JsFileDone>(json); summary.TimeTaken = jsFileDone.TimeTaken; callback.FileFinished(testContext.InputTestFile, summary); break; case "TestStart": jsTestCase = jsonSerializer.Deserialize<JsTestCase>(json); jsTestCase.TestCase.InputTestFile = testContext.InputTestFile; callback.TestStarted(jsTestCase.TestCase); break; case "TestDone": jsTestCase = jsonSerializer.Deserialize<JsTestCase>(json); jsTestCase.TestCase.InputTestFile = testContext.InputTestFile; AddLineNumber(referencedFile, testIndex, jsTestCase); testIndex++; callback.TestFinished(jsTestCase.TestCase); summary.AddTestCase(jsTestCase.TestCase); break; case "Log": var log = jsonSerializer.Deserialize<JsLog>(json); // This is an internal log message if (log.Log.Message.StartsWith(internalLogPrefix)) { ChutzpahTracer.TraceInformation("Phantom Log - {0}",log.Log.Message.Substring(internalLogPrefix.Length).Trim()); break; } log.Log.InputTestFile = testContext.InputTestFile; callback.FileLog(log.Log); summary.Logs.Add(log.Log); break; case "Error": var error = jsonSerializer.Deserialize<JsError>(json); error.Error.InputTestFile = testContext.InputTestFile; callback.FileError(error.Error); summary.Errors.Add(error.Error); break; } } catch (SerializationException e) { // Ignore malformed json and move on ChutzpahTracer.TraceError(e, "Recieved malformed json from Phantom in this line: '{0}'", line); } } return summary; }