Exemple #1
0
        public void Handle(ScreenshotFileSavedEvent eventData, AtataContext context)
        {
            string relativeFilePath = eventData.FilePath.Replace(ExtentContext.WorkingDirectoryPath, null);

            ExtentContext.ResolveFor(context).Test.Log(
                Status.Info,
                CreateMediaEntityModelProvider(relativeFilePath, eventData.ScreenshotInfo.Title));
        }
        public void Log(LogEventInfo eventInfo)
        {
            Status status = ResolveLogStatus(eventInfo);

            string completeMessage = BuildCompleteMessage(eventInfo);

            completeMessage = NormalizeMessage(completeMessage);

            ExtentContext extentContext = ExtentContext.ResolveFor(eventInfo.Context);

            extentContext.Test.Log(status, completeMessage);
            extentContext.LastLogEvent = eventInfo;
        }
        private static Status ResolveLogStatus(LogEventInfo eventInfo)
        {
            switch (eventInfo.Level)
            {
            case LogLevel.Trace:
                return(Status.Debug);

            case LogLevel.Debug:
                return(Status.Debug);

            case LogLevel.Info:
                if (eventInfo.SectionEnd is VerificationLogSection)
                {
                    if (eventInfo.SectionEnd.Exception != null)
                    {
                        return(Status.Fail);
                    }
                    else if (!eventInfo.SectionEnd.Message.StartsWith("Wait", StringComparison.Ordinal))
                    {
                        var lastLogLevel = ExtentContext.ResolveFor(eventInfo.Context)
                                           .LastLogEvent.Level;

                        if (lastLogLevel != LogLevel.Error && lastLogLevel != LogLevel.Warn)
                        {
                            return(Status.Pass);
                        }
                    }
                }

                return(Status.Info);

            case LogLevel.Warn:
                return(Status.Warning);

            case LogLevel.Error:
                return(Status.Fail);

            case LogLevel.Fatal:
                return(Status.Fatal);

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(eventInfo.Level, $"{nameof(eventInfo)}.{nameof(LogEventInfo.Level)}");
            }
        }