public void TestFinished(TestContext context, TestCase testCase)
 {
     lock (sync)
     {
         nestedCallback.TestFinished(context, testCase);
     }
 }
Exemplo n.º 2
0
 public void TestFinished(TestCase testCase)
 {
     lock (sync)
     {
         nestedCallback.TestFinished(testCase);
     }
 }
        private void FireErrorOutput(TestContext testContext, ITestMethodRunnerCallback callback, StreamingTestFileContext testFileContext, JsRunnerOutput jsRunnerOutput)
        {
            var error = jsRunnerOutput as JsError;

            error.Error.InputTestFile = testFileContext.ReferencedFile.Path;
            error.Error.PathFromTestSettingsDirectory = testFileContext.ReferencedFile.PathFromTestSettingsDirectory;
            callback.FileError(testContext, error.Error);
            testFileContext.TestFileSummary.Errors.Add(error.Error);

            if (testFileContext.TestContext.TestFileSettings.CreateFailedTestForFileError.GetValueOrDefault())
            {
                var fileErrorTest = new TestCase();
                fileErrorTest.InputTestFile = testFileContext.ReferencedFile.Path;
                fileErrorTest.PathFromTestSettingsDirectory = testFileContext.ReferencedFile.PathFromTestSettingsDirectory;
                fileErrorTest.TestName = string.Format("!! File Error #{0} - Error encountered outside of test case execution !!", testFileContext.TestFileSummary.Errors.Count);
                fileErrorTest.TestResults.Add(new TestResult {
                    Passed = false, StackTrace = error.Error.StackAsString ?? error.Error.FormatStackObject(), Message = error.Error.Message
                });
                callback.TestStarted(testContext, fileErrorTest);
                callback.TestFinished(testContext, fileErrorTest);

                testFileContext.TestFileSummary.AddTestCase(fileErrorTest);
            }

            ChutzpahTracer.TraceError("Error received from Phantom {0}", error.Error.Message);
        }
Exemplo n.º 4
0
        private void FireTestFinished(ITestMethodRunnerCallback callback, TestFileContext testFileContext, JsRunnerOutput jsRunnerOutput, int testIndex)
        {
            var jsTestCase = jsRunnerOutput as JsTestCase;

            jsTestCase.TestCase.InputTestFile = testFileContext.ReferencedFile.Path;
            AddLineNumber(testFileContext.ReferencedFile, testIndex, jsTestCase);
            callback.TestFinished(jsTestCase.TestCase);
            testFileContext.TestFileSummary.AddTestCase(jsTestCase.TestCase);
        }
Exemplo n.º 5
0
        private void FireTestFinished(ITestMethodRunnerCallback callback, StreamingTestFileContext testFileContext, JsRunnerOutput jsRunnerOutput, int testIndex)
        {
            var jsTestCase = jsRunnerOutput as JsTestCase;

            jsTestCase.TestCase.InputTestFile = testFileContext.ReferencedFile.Path;
            AddLineNumber(testFileContext.ReferencedFile, testIndex, jsTestCase);
            callback.TestFinished(jsTestCase.TestCase);
            testFileContext.TestFileSummary.AddTestCase(jsTestCase.TestCase);

            ChutzpahTracer.TraceInformation("Test Case Finished:'{0}'", jsTestCase.TestCase.GetDisplayName());
        }
Exemplo n.º 6
0
            public bool TestFinished(TestMethod testMethod)
            {
                ++Total;

                var lastRunResult = testMethod.RunResults[testMethod.RunResults.Count - 1];

                if (lastRunResult is TestFailedResult)
                {
                    ++Failed;
                }
                if (lastRunResult is TestSkippedResult)
                {
                    ++Skipped;
                }

                Time += lastRunResult.Duration;

                return(innerCallback.TestFinished(testMethod));
            }
 /// <inheritdoc/>
 public bool TestFinished(string name, string type, string method)
 {
     // TODO: Cache test method lookup?
     return(callback.TestFinished(testClass.GetMethod(method)));
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        private void FireTestFinished(ITestMethodRunnerCallback callback, StreamingTestFileContext testFileContext, JsRunnerOutput jsRunnerOutput, int testIndex)
        {

            var jsTestCase = jsRunnerOutput as JsTestCase;
            jsTestCase.TestCase.InputTestFile = testFileContext.ReferencedFile.Path;
            AddLineNumber(testFileContext.ReferencedFile, testIndex, jsTestCase);
            callback.TestFinished(jsTestCase.TestCase);
            testFileContext.TestFileSummary.AddTestCase(jsTestCase.TestCase);


            ChutzpahTracer.TraceInformation("Test Case Finished:'{0}'", jsTestCase.TestCase.GetDisplayName());
            
        }
Exemplo n.º 10
0
 private void FireTestFinished(ITestMethodRunnerCallback callback, StreamingTestFileContext testFileContext, JsRunnerOutput jsRunnerOutput, int testIndex)
 {
     var jsTestCase = jsRunnerOutput as JsTestCase;
     jsTestCase.TestCase.InputTestFile = testFileContext.ReferencedFile.Path;
     AddLineNumber(testFileContext.ReferencedFile, testIndex, jsTestCase);
     callback.TestFinished(jsTestCase.TestCase);
     testFileContext.TestFileSummary.AddTestCase(jsTestCase.TestCase);
 }
Exemplo n.º 11
0
        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;
        }