Exemplo n.º 1
0
        public override void AfterTest(ITest test)
        {
            TestContext.Progress.WriteLine("Test run completed.");

            try
            {
                var results = TestRunResultAccumulator.Instance.TestResults;

                var exercise = new Exercise
                {
                    CourseCode    = _courseCode,
                    ChapterNumber = _chapter,
                    ExerciseCode  = _exerciseCode,
                };

                var testRun = new ExerciseTestRun
                {
                    Exercise = exercise,
                    Results  = results,
                };

                if (!string.IsNullOrEmpty(_sourceCodeRelativeFilePaths))
                {
                    TestContext.Progress.WriteLine($"Reading source code files: {_sourceCodeRelativeFilePaths}");
                    testRun.SourceCode = SourceCodeRetriever.ReadSourceCodeFiles(_sourceCodeRelativeFilePaths);
                }

                SendTestResults(testRun);
            }
            catch (Exception ex)
            {
                TestContext.Error.WriteLine("Something went wrong while sending the test results.");
                TestContext.Error.WriteLine($"Exception: {ex}");
            }
        }
        public override void AfterTest(ITest test)
        {
            try
            {
                var results = TestRunResultAccumulator.Instance.TestResults;

                var projectComponent = new ProjectComponent
                {
                    CourseCode    = _courseCode,
                    ProjectCode   = _projectCode,
                    ComponentCode = _componentCode,
                };

                var testRun = new ProjectComponentTestRun
                {
                    ProjectComponent = projectComponent,
                    Results          = results,
                };

                if (!string.IsNullOrEmpty(_sourceCodeRelativeFilePaths))
                {
                    TestContext.Progress.WriteLine($"Reading source code files: {_sourceCodeRelativeFilePaths}");
                    testRun.SourceCode = SourceCodeRetriever.ReadSourceCodeFiles(_sourceCodeRelativeFilePaths);
                }

                SendTestResults(testRun);
            }
            catch (Exception ex)
            {
                TestContext.Error.WriteLine("Something went wrong while sending the test results.");
                TestContext.Error.WriteLine($"Exception: {ex}");
            }
        }