Example #1
0
        private List <TestInformationReportDTO> GetSpecflowTestesToReport(TestResultContentFile trxObj)
        {
            var testList = new List <TestInformationReportDTO>();

            if (trxObj != null)
            {
                var specFlowTest = trxObj.Results.Where(x => x.Output != null && !string.IsNullOrEmpty(x.Output.StdOut) && (x.Output.StdOut.IndexOf(ExtendReportConsts.Given) == 0 || x.Output.StdOut.IndexOf(ExtendReportConsts.Dado) == 0)).ToList();
                specFlowTest.ForEach(t =>
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(t.TestName))
                        {
                            var scenarioName   = GetSpecScenarioName(t.TestName);
                            var executationId  = t.ExecutionId;
                            var testDefinition = trxObj.TestDefinitions.Where(x => x.Execution.Id == executationId).FirstOrDefault();
                            if (testDefinition != null)
                            {
                                var featureName   = GetSpecFeatureName(testDefinition.TestMethod.ClassName);
                                var listaSteps    = new List <TestStepDTO>();
                                var rawStdOutRows = t.Output.StdOut.Split(Environment.NewLine);
                                var lastStepType  = string.Empty;
                                for (var i = 0; i < rawStdOutRows.Length; i += 2)
                                {
                                    var stepInfo        = rawStdOutRows[i];
                                    var stepResult      = rawStdOutRows[i + 1];
                                    var stepName        = stepInfo;
                                    var currentStepType = stepInfo.Split(" ")[0];

                                    var stepTypeToUse = GetStepTypeWord(currentStepType, lastStepType);
                                    lastStepType      = stepTypeToUse;
                                    var gherkinStep   = GetStepGherkinKeyword(stepTypeToUse);
                                    var step          = new TestStepDTO(gherkinStep)
                                    {
                                        Name        = stepName,
                                        Description = stepName,
                                        EndTime     = t.EndTime,
                                        StartTime   = t.StartTime,
                                        Error       = GetErrorInStep(t, stepResult)
                                    };
                                    listaSteps.Add(step);
                                }
                                AddTestToReport(false, featureName, scenarioName, listaSteps, testList);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, $"Erro ao processar o teste SPEC {t.TestName}");
                    }
                });
            }
            return(testList);
        }
Example #2
0
        public hOOt.Document CreateTestStep(TestStepDTO testStep)
        {
            var name = EntityDocument.CreateName(testStep.TestStepID);
            var descriptionWithResult =
                _textOperations.Prepare(string.Format("{0} {1}", testStep.Description ?? string.Empty,
                                                      testStep.Result ?? string.Empty));

            return(new hOOt.Document(name, descriptionWithResult)
            {
                DocNumber = -1
            });
        }
Example #3
0
        private List <TestInformationReportDTO> GetUnitTestesToReport(TestResultContentFile trxInformation)
        {
            var testList = new List <TestInformationReportDTO>();

            if (trxInformation != null)
            {
                var unitTests = trxInformation.Results.Where(x => x.Output == null || (x.Output.StdOut == null)).ToList();
                unitTests.ForEach(t =>
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(t.TestName))
                        {
                            var splitedTestName = t.TestName.Split(".");
                            var stepName        = splitedTestName[splitedTestName.Length - 1];
                            var scenarioName    = splitedTestName[splitedTestName.Length - 2];
                            var featureName     = t.TestName.Replace($".{scenarioName}.{stepName}", string.Empty);
                            var step            = new TestStepDTO()
                            {
                                Name        = stepName,
                                Description = stepName,
                                EndTime     = t.EndTime,
                                StartTime   = t.StartTime,
                                Error       = GetErrorInStep(t)
                            };
                            AddTestToReport(true, featureName, scenarioName, new List <TestStepDTO> {
                                step
                            }, testList);
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, $"Erro ao processar o teste UNITÁRIO {t.TestName}");
                    }
                });
            }
            return(testList);
        }
Example #4
0
 private void RemoveTestStepIndex(TestStepDTO testStepDto)
 {
     RebuildOrAction(() => _entityIndexer.RemoveTestStepIndex(testStepDto, DocumentIndexOptimizeSetup.DeferredOptimize));
 }
Example #5
0
 private void UpdateTestStepIndex(TestStepDTO testStepDto, ICollection <TestStepField> changedTestStepFields)
 {
     RebuildOrAction(() => _entityIndexer.UpdateTestStepIndex(testStepDto, changedTestStepFields, Maybe.Nothing, DocumentIndexOptimizeSetup.DeferredOptimize));
 }