diff --git a/ExtentReports.Tests/Base.cs b/ExtentReports.Tests/Base.cs index 7038db3..3a4e869 100644 --- a/ExtentReports.Tests/Base.cs +++ b/ExtentReports.Tests/Base.cs @@ -17,7 +17,7 @@ protected void Setup() { string dir = TestContext.CurrentContext.TestDirectory + "\\"; var fileName = this.GetType().ToString() + ".html"; - ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(dir + fileName); + ExtentV3HtmlReporter htmlReporter = new ExtentV3HtmlReporter(dir + fileName); _extent = new ExtentReports(); _extent.AttachReporter(htmlReporter); diff --git a/ExtentReports.Tests/Core/BuildsReportWithoutTests.cs b/ExtentReports.Tests/Core/BuildsReportWithoutTests.cs index 9d4bdf8..bc0bf07 100644 --- a/ExtentReports.Tests/Core/BuildsReportWithoutTests.cs +++ b/ExtentReports.Tests/Core/BuildsReportWithoutTests.cs @@ -13,7 +13,7 @@ public class BuildsReportWithoutTests public void BuildReportWithoutTests() { var fileName = TestContext.CurrentContext.Test.Name + ".html"; - var reporter = new ExtentHtmlReporter(fileName); + var reporter = new ExtentV3HtmlReporter(fileName); var extent = new ExtentReports(); extent.AttachReporter(reporter); extent.Flush(); diff --git a/ExtentReports.Tests/Service/ExtentService.cs b/ExtentReports.Tests/Service/ExtentService.cs index eff555b..1d6f747 100644 --- a/ExtentReports.Tests/Service/ExtentService.cs +++ b/ExtentReports.Tests/Service/ExtentService.cs @@ -15,7 +15,7 @@ public class ExtentService static ExtentService() { - var htmlReporter = new ExtentHtmlReporter(TestContext.CurrentContext.TestDirectory + "\\Extent.html"); + var htmlReporter = new ExtentV3HtmlReporter(TestContext.CurrentContext.TestDirectory + "\\Extent.html"); htmlReporter.Config.DocumentTitle = "Extent/NUnit Samples"; htmlReporter.Config.ReportName = "Extent/NUnit Samples"; htmlReporter.Config.Theme = Theme.Standard; diff --git a/ExtentReports/Core/ExtentObservable.cs b/ExtentReports/Core/ExtentObservable.cs index 4009c88..f501a3b 100644 --- a/ExtentReports/Core/ExtentObservable.cs +++ b/ExtentReports/Core/ExtentObservable.cs @@ -206,9 +206,16 @@ private void RefreshStatusList(List testList) return; } - _statusMap.Clear(); var distinctStatusList = testList.Select(x => x.Status).Distinct(); - distinctStatusList.ToList().ForEach(x => _statusMap.Add(x, false)); + + foreach (var s in distinctStatusList) + { + if (!_statusMap.ContainsKey(s)) + { + _statusMap.Add(s, false); + } + } + // recursively, do the same for child tests foreach (var test in testList.ToList()) { @@ -350,6 +357,7 @@ private void NotifyReporters() var reportAggregates = new ReportAggregates { TestList = _testList, + StatusList = _statusList, ReportStatusStats = this.ReportStatusStats, AuthorContext = this.AuthorContext, CategoryContext = this.CategoryContext, diff --git a/ExtentReports/ExtentReports.csproj b/ExtentReports/ExtentReports.csproj index 8ca1a73..04dcf20 100644 --- a/ExtentReports/ExtentReports.csproj +++ b/ExtentReports/ExtentReports.csproj @@ -151,6 +151,7 @@ + @@ -167,9 +168,12 @@ + - + + + @@ -189,26 +193,26 @@ - - - - + + + + PreserveNewest - - + + PreserveNewest - + PreserveNewest Designer - + PreserveNewest Designer - - + + PreserveNewest @@ -224,6 +228,19 @@ + + + + + + + + + + + + + diff --git a/ExtentReports/Model/Media.cs b/ExtentReports/Model/Media.cs index afc0e8c..28512b1 100644 --- a/ExtentReports/Model/Media.cs +++ b/ExtentReports/Model/Media.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Threading; using MongoDB.Bson; @@ -12,13 +13,32 @@ public class Media public ObjectId ReportObjectId { get; set; } public ObjectId TestObjectId { get; set; } public ObjectId LogObjectId { get; set; } + public long FileSize { get; set; } public string Name { get; set; } public string Description { get; set; } - public string Path { get; set; } public string Title { get; set; } public string Base64String { get; set; } public int Sequence { get; private set; } = Interlocked.Increment(ref _seq); + public string Path + { + get + { + return _path; + } + set + { + _path = value; + + Name = !string.IsNullOrEmpty(Name) ? Name : System.IO.Path.GetFileName(value); + if (File.Exists(value)) + { + FileSize = new FileInfo(value).Length; + } + } + } + private static int _seq; + private string _path; } } diff --git a/ExtentReports/Model/ScreenCapture.cs b/ExtentReports/Model/ScreenCapture.cs index 7ae3a7b..bbb75d8 100644 --- a/ExtentReports/Model/ScreenCapture.cs +++ b/ExtentReports/Model/ScreenCapture.cs @@ -32,5 +32,21 @@ public string SourceIcon ""; } } + + public string ScreenCapturePath + { + get + { + return !string.IsNullOrEmpty(base.Path) ? base.Path : Base64String; + } + } + + public bool IsBase64 + { + get + { + return !string.IsNullOrEmpty(Base64String); + } + } } } diff --git a/ExtentReports/Model/Test.cs b/ExtentReports/Model/Test.cs index 5c7e44b..009f294 100644 --- a/ExtentReports/Model/Test.cs +++ b/ExtentReports/Model/Test.cs @@ -110,6 +110,14 @@ public bool HasLog } } + public bool HasAttributes + { + get + { + return HasAuthor || HasCategory || HasDevice; + } + } + public GenericStructure CategoryContext { get diff --git a/ExtentReports/Reporter/BasicFileReporter.cs b/ExtentReports/Reporter/BasicFileReporter.cs index 0a82dd5..22a4cb8 100644 --- a/ExtentReports/Reporter/BasicFileReporter.cs +++ b/ExtentReports/Reporter/BasicFileReporter.cs @@ -26,6 +26,8 @@ public abstract class BasicFileReporter : ConfigurableReporter public List TestList { get; protected internal set; } + public List StatusList { get; protected internal set; } + public TestAttributeTestContextProvider AuthorContext { get; protected internal set; } public TestAttributeTestContextProvider CategoryContext { get; protected internal set; } @@ -62,6 +64,7 @@ protected void Initialize(BasicFileConfiguration userConfig) public override void Flush(ReportAggregates reportAggregates) { TestList = reportAggregates.TestList; + StatusList = reportAggregates.StatusList; ReportStatusStats = reportAggregates.ReportStatusStats; AuthorContext = reportAggregates.AuthorContext; CategoryContext = reportAggregates.CategoryContext; @@ -144,12 +147,7 @@ public override void Stop() public bool ContainsStatus(Status status) { - return true; - } - - public bool ContainsStatus(string status) - { - return true; + return StatusList.Contains(status); } } } diff --git a/ExtentReports/Reporter/ExtentHtmlReporter.cs b/ExtentReports/Reporter/ExtentHtmlReporter.cs index 75a46cb..67c38ff 100644 --- a/ExtentReports/Reporter/ExtentHtmlReporter.cs +++ b/ExtentReports/Reporter/ExtentHtmlReporter.cs @@ -1,6 +1,6 @@ using AventStack.ExtentReports.Core; -using AventStack.ExtentReports.Views.Html; using AventStack.ExtentReports.Reporter.Configuration; +using AventStack.ExtentReports.Views.Html; using RazorEngine.Templating; @@ -20,7 +20,7 @@ public class ExtentHtmlReporter : BasicFileReporter private static readonly string TemplateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); private static readonly string HtmlTemplateFolderPath = Path.Combine(TemplateFolderPath, "Html"); - public ExtentHtmlReporter(string filePath) : base(filePath) + public ExtentHtmlReporter(string folderPath) : base(folderPath) { Config = new ExtentHtmlReporterConfiguration(this); Initialize(Config); @@ -31,8 +31,33 @@ public ExtentHtmlReporter(string filePath) : base(filePath) public override void Flush(ReportAggregates reportAggregates) { base.Flush(reportAggregates); + + Directory.CreateDirectory(SavePath); + var source = RazorEngineManager.Instance.Razor.RunCompile("Index", typeof(ExtentHtmlReporter), this); - File.WriteAllText(SavePath, source); + File.WriteAllText(SavePath + "index.html", source); + source = RazorEngineManager.Instance.Razor.RunCompile("Dashboard", typeof(ExtentHtmlReporter), this); + File.WriteAllText(SavePath + "dashboard.html", source); + if (AuthorContext.Context.Count > 0) + { + source = RazorEngineManager.Instance.Razor.RunCompile("Author", typeof(ExtentHtmlReporter), this); + File.WriteAllText(SavePath + "author.html", source); + } + if (CategoryContext.Context.Count > 0) + { + source = RazorEngineManager.Instance.Razor.RunCompile("Tag", typeof(ExtentHtmlReporter), this); + File.WriteAllText(SavePath + "tag.html", source); + } + if (DeviceContext.Context.Count > 0) + { + source = RazorEngineManager.Instance.Razor.RunCompile("Device", typeof(ExtentHtmlReporter), this); + File.WriteAllText(SavePath + "device.html", source); + } + if (ExceptionInfoContext.Context.Count > 0) + { + source = RazorEngineManager.Instance.Razor.RunCompile("Exception", typeof(ExtentHtmlReporter), this); + File.WriteAllText(SavePath + "exception.html", source); + } } public override void Start() @@ -45,18 +70,22 @@ private void AddTemplates() { string[] templates = new string[] { + "Author", + "Dashboard", + "Device", + "Exception", "Index", - "Head", - "Nav", - "Test.Test", - "Test.Charts", - "Author.Author", - "Category.Category", - "Dashboard.Dashboard", - "Exception.Exception", - "TestRunner.Logs" + "Tag", + "Partials.Attributes", + "Partials.AttributesView", + "Partials.Head", + "Partials.Log", + "Partials.Navbar", + "Partials.RecurseNodes", + "Partials.Scripts", + "Partials.Sidenav" }; - + foreach (string template in templates) { string resourceName = typeof(IHtmlMarker).Namespace + "." + template + ".cshtml"; diff --git a/ExtentReports/Reporter/ExtentV3HtmlReporter.cs b/ExtentReports/Reporter/ExtentV3HtmlReporter.cs new file mode 100644 index 0000000..a37753a --- /dev/null +++ b/ExtentReports/Reporter/ExtentV3HtmlReporter.cs @@ -0,0 +1,78 @@ +using AventStack.ExtentReports.Core; +using AventStack.ExtentReports.Views.V3Html; +using AventStack.ExtentReports.Reporter.Configuration; + +using RazorEngine.Templating; + +using System; +using System.IO; + +namespace AventStack.ExtentReports.Reporter +{ + /// + /// The ExtentHtmlReporter creates a rich standalone HTML file. It allows several configuration options + /// via the Configuration() method. + /// + public class ExtentV3HtmlReporter : BasicFileReporter + { + public new string ReporterName => "html"; + + private static readonly string TemplateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); + private static readonly string HtmlTemplateFolderPath = Path.Combine(TemplateFolderPath, "V3Html"); + + public ExtentV3HtmlReporter(string filePath) : base(filePath) + { + Config = new ExtentHtmlReporterConfiguration(this); + Initialize(Config); + } + + public ExtentHtmlReporterConfiguration Config { get; } + + public override void Flush(ReportAggregates reportAggregates) + { + base.Flush(reportAggregates); + var source = RazorEngineManager.Instance.Razor.RunCompile("V3Index", typeof(ExtentV3HtmlReporter), this); + File.WriteAllText(SavePath, source); + } + + public override void Start() + { + base.Start(); + AddTemplates(); + } + + private void AddTemplates() + { + string[] templates = new string[] + { + "V3Index", + "V3Head", + "V3Nav", + "Test.V3Test", + "Test.V3Charts", + "Author.V3Author", + "Category.V3Category", + "Dashboard.V3Dashboard", + "Exception.V3Exception", + "TestRunner.V3Logs" + }; + + foreach (string template in templates) + { + string resourceName = typeof(IV3HtmlMarker).Namespace + "." + template + ".cshtml"; + using (var resourceStream = typeof(IV3HtmlMarker).Assembly.GetManifestResourceStream(resourceName)) + { + using (var reader = new StreamReader(resourceStream)) + { + if (resourceStream != null) + { + var arr = template.Split('.'); + var name = arr.Length > 1 ? arr[arr.Length - 1] : arr[0]; + RazorEngineManager.Instance.Razor.AddTemplate(name, reader.ReadToEnd()); + } + } + } + } + } + } +} diff --git a/ExtentReports/ViewDefs/MaterialIcon.cs b/ExtentReports/ViewDefs/MaterialIcon.cs index 532291b..e717c76 100644 --- a/ExtentReports/ViewDefs/MaterialIcon.cs +++ b/ExtentReports/ViewDefs/MaterialIcon.cs @@ -3,7 +3,7 @@ namespace AventStack.ExtentReports.ViewDefs { - public class MaterialIcon + public static class MaterialIcon { private static Dictionary _dic = new Dictionary(); diff --git a/ExtentReports/ViewDefs/TWBSIcon.cs b/ExtentReports/ViewDefs/TWBSIcon.cs new file mode 100644 index 0000000..bea764b --- /dev/null +++ b/ExtentReports/ViewDefs/TWBSIcon.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; + +namespace AventStack.ExtentReports.ViewDefs +{ + public static class TWBSIcon + { + private static Dictionary _dic = new Dictionary(); + + public static void Override(Status status, string icon) + { + _dic.Add(status, icon); + } + + public static string GetIcon(Status status) + { + if (_dic.ContainsKey(status)) + return _dic[status]; + + switch (status) + { + case Status.Fail: + return "times"; + case Status.Fatal: + return "times"; + case Status.Error: + return "exclamation"; + case Status.Warning: + return"warning"; + case Status.Skip: + return "long-arrow-right"; + case Status.Pass: + return "check"; + case Status.Debug: + return "low_priority"; + case Status.Info: + return "info"; + default: + return "help"; + } + } + } +} diff --git a/ExtentReports/Views/Html/Author.cshtml b/ExtentReports/Views/Html/Author.cshtml new file mode 100644 index 0000000..b333a91 --- /dev/null +++ b/ExtentReports/Views/Html/Author.cshtml @@ -0,0 +1,49 @@ +@using RazorEngine +@using RazorEngine.Templating + + + +@Include("Head") + +
+
+ @Include("Navbar") + @Include("Sidenav") +
+
+
+
+ +
+
    + @foreach (var author in Model.AuthorContext.Context) + { + @Include("AttributesView", author) + } +
+
+
+
+
+
+
+
+
+ @Include("Scripts") + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Dashboard.cshtml b/ExtentReports/Views/Html/Dashboard.cshtml new file mode 100644 index 0000000..d33fcf4 --- /dev/null +++ b/ExtentReports/Views/Html/Dashboard.cshtml @@ -0,0 +1,446 @@ +@using AventStack.ExtentReports + +@{ + var bdd = Model.TestList[0].IsBehaviorDrivenType; + + var boxSize = "col-md-12"; + if (Model.ReportStatusStats.ChildCount > 0) { + boxSize = "col-sm-12 col-md-6"; + } + if (bdd || Model.ReportStatusStats.GrandChildCount > 0) { + boxSize = "col-sm-12 col-md-4"; + } + + var chartWidth="115"; + var chartHeight="90"; + var chartBoxHeight="94px"; + + var parentHeading="Classes"; + var childHeading="Tests"; + var grandChildHeading="Steps"; + var parentLabel="class(es)"; + var childLabel = "test(s)"; + var grandchildLabel="step(s)"; + + if (bdd) { + parentHeading="Features"; + childHeading="Scenarios"; + grandChildHeading="Steps"; + parentLabel="feature(s)"; + childLabel="scenario(s)"; + } else { + if (Model.AnalysisStrategy == AnalysisStrategy.Test) { + parentHeading="Tests"; + childHeading="Steps"; + grandChildHeading=""; + parentLabel="test(s)"; + childLabel=grandchildLabel; + } + } + + var runDuration = DateTime.Now - Model.StartTime; +} + + + + @Include("Head") + +
+
+ + @Include("Sidenav") +
+
+
+
+
+
+
+
@parentHeading
+
+
+
+ +
+
+ +
+
+ @if (Model.ReportStatusStats.ChildCount > 0) + { +
+
+
+
@childHeading
+
+
+
+ +
+
+ +
+
+ } + @if (Model.ReportStatusStats.GrandChildCount > 0) + { +
+
+
+
@grandChildHeading
+
+
+
+ +
+
+ +
+
+ } +
+
+
+
+
+
+
+

@parentHeading

+

@Model.ReportStatusStats.ParentCount

+ + + @Math.Round(Model.ReportStatusStats.ParentPercentagePass, 2)% + +
+
+ +
+
+
+
+
+ @if (Model.ReportStatusStats.ChildCount > 0) + { +
+
+
+
+
+

@childHeading

+

@Model.ReportStatusStats.ChildCount

+ + + @Math.Round(Model.ReportStatusStats.ChildPercentagePass, 2)% + +
+
+ +
+
+
+
+
+ } +
+
+
+
+
+

Start

+
@Model.StartTime
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+

End

+
@Model.EndTime
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+

Duration

+
@runDuration
+ +
+
+ +
+
+
+
+
+
+ @if (Model.MasterConfig.GetValue("enableTimeline") == "true") + { +
+
+
+
+
Timeline
+
+
+
+ +
+
+
+
+
+ } +
+ @if (Model.AuthorContext.Context.Count > 0) + { +
+
+
+
Author
+
+
+ + + + + + + + + + + + @foreach(var context in Model.AuthorContext.Context) + { + + + + + + + + } + +
NamePassedFailedOthersPassed %
@context.Name@context.Passed@context.Failed@context.Others@(Math.Round(((double)context.Passed/(double)context.Count)*100, 2))%
+
+
+
+ } + @if (Model.CategoryContext.Context.Count > 0) + { +
+
+
+
Tags
+
+
+ + + + + + + + + + + + @foreach(var context in Model.CategoryContext.Context) + { + + + + + + + + } + +
NamePassedFailedOthersPassed %
@context.Name@context.Passed@context.Failed@context.Others@(Math.Round(((double)context.Passed/(double)context.Count)*100, 2))%
+
+
+
+ } + @if (Model.DeviceContext.Context.Count > 0) + { +
+
+
+
Device
+
+
+ + + + + + + + + + + + @foreach(var context in Model.DeviceContext.Context) + { + + + + + + + + } + +
NamePassedFailedOthersPassed %
@context.Name@context.Passed@context.Failed@context.Others@(Math.Round(((double)context.Passed/(double)context.Count)*100, 2))%
+
+
+
+ } + @if (Model.SystemAttributeContext.Count > 0) + { +
+
+
+
Environment
+
+
+ + + + + + + + + @foreach (var attr in Model.SystemAttributeContext.SystemAttributeCollection) + { + + + + + } + +
NameValue
@attr.Name@attr.Value
+
+
+
+ } +
+
+
+
+
+
+ + @if (Model.MasterConfig.GetValue("enableTimeline") == "true") + { + var json = ""; + for (int ix = 0; ix < Model.TestList.Count; ix++) { + json += "\"" + Model.TestList[ix].Name + "\"" + ":" + Model.TestList[ix].RunDuration.TotalSeconds; + if (ix != Model.TestList.Count-1) { + json += ","; + } + } + + } + @Include("Scripts") + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Device.cshtml b/ExtentReports/Views/Html/Device.cshtml new file mode 100644 index 0000000..2b7211d --- /dev/null +++ b/ExtentReports/Views/Html/Device.cshtml @@ -0,0 +1,49 @@ +@using RazorEngine +@using RazorEngine.Templating + + + +@Include("Head") + +
+
+ @Include("Navbar") + @Include("Sidenav") +
+
+
+
+ +
+
    + @foreach (var device in Model.DeviceContext.Context) + { + @Include("AttributesView", device) + } +
+
+
+
+
+
+
+
+
+ @Include("Scripts") + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Exception.cshtml b/ExtentReports/Views/Html/Exception.cshtml new file mode 100644 index 0000000..eeffd7c --- /dev/null +++ b/ExtentReports/Views/Html/Exception.cshtml @@ -0,0 +1,49 @@ +@using RazorEngine +@using RazorEngine.Templating + + + +@Include("Head") + +
+
+ @Include("Navbar") + @Include("Sidenav") +
+
+
+
+ +
+
    + @foreach (var ex in Model.ExceptionInfoContext.Context) + { + @Include("AttributesView", ex) + } +
+
+
+
+
+
+
+
+
+ @Include("Scripts") + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/IHtmlMarker.cs b/ExtentReports/Views/Html/IHtml2Marker.cs similarity index 100% rename from ExtentReports/Views/Html/IHtmlMarker.cs rename to ExtentReports/Views/Html/IHtml2Marker.cs diff --git a/ExtentReports/Views/Html/Index.cshtml b/ExtentReports/Views/Html/Index.cshtml index 5b6814d..a22e068 100644 --- a/ExtentReports/Views/Html/Index.cshtml +++ b/ExtentReports/Views/Html/Index.cshtml @@ -1,84 +1,207 @@ +@using AventStack.ExtentReports @using RazorEngine @using RazorEngine.Templating - - @Include("Head") - - -
- desktop_windows -
- - @Include("Nav") - - -
- @Include("Test") - @Include("Author") - @Include("Category") - @Include("Exception") - @Include("Dashboard") - @Include("Logs") -
- - - @if (Model.MasterConfig.GetValue("enableTimeline") == "true") - { - var json = ""; - for (int ix = 0; ix < Model.TestList.Count; ix++) { - json += "\"" + Model.TestList[ix].Name + "\"" + ":" + Model.TestList[ix].RunDuration.TotalSeconds; - if (ix != Model.TestList.Count-1) { - json += ","; - } - } - - } - - @if (Model.MasterConfig.GetValue("chartVisibleOnOpen") == "false") - { - - } - - +@Include("Head") + + +
+
+ @Include("Navbar") + @Include("Sidenav") +
+
+
+
+
+ +
    +
  • + +
  • + @if (Model.AuthorContext.Context.Count > 0) + { +
  • + +
  • + } + @if (Model.CategoryContext.Context.Count > 0) + { +
  • + +
  • + } + @if (Model.DeviceContext.Context.Count > 0) + { +
  • + +
  • + } +
+
+
+
    + @foreach (var test in Model.TestList) + { + string authors = "", devices = "", tags = ""; + foreach (var author in test.AuthorContext.All()) + { + authors += author.Name + " "; + } + foreach (var device in test.DeviceContext.All()) + { + devices += device.Name + " "; + } + foreach (var tag in test.CategoryContext.All()) + { + tags += tag.Name + " "; + } +
  • +
    + @test.Status +
    +
    +
    +

    @test.Name

    +

    @test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'")

    + @test.StartTime.ToString("HH:mm:ss tt") +
    +
    +
    +
    +
    +
    +

    @test.Name

    + @test.StartTime + @test.EndTime + @test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'") +
    + @if (test.HasAttributes) + { +
    + @Include("Attributes", test) +
    + } + @if (!string.IsNullOrEmpty(test.Description)) + { +
    + @test.Description +
    + } +
    + +
    +
    + @if (test.HasLog) + { + @Include("Log", test) + } +
    + @if (test.HasScreenCapture) + { +
    + +
    + } + @if (test.HasChildren) + { + @Include("RecurseNodes", test) + } +
    +
  • + } +
+
+
+
+
+
+
+
+
+ @Include("Scripts") + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/Attributes.cshtml b/ExtentReports/Views/Html/Partials/Attributes.cshtml new file mode 100644 index 0000000..eeee68c --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Attributes.cshtml @@ -0,0 +1,26 @@ +@if (Model.HasAttributes) +{ +
+ @if (Model.HasAuthor) + { + foreach (var author in Model.AuthorContext.All()) + { + @author.Name + } + } + @if (Model.HasCategory) + { + foreach (var category in Model.CategoryContext.All()) + { + @category.Name + } + } + @if (Model.HasDevice) + { + foreach (var device in Model.DeviceContext.All()) + { + @device.Name + } + } +
+} \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/AttributesView.cshtml b/ExtentReports/Views/Html/Partials/AttributesView.cshtml new file mode 100644 index 0000000..c139266 --- /dev/null +++ b/ExtentReports/Views/Html/Partials/AttributesView.cshtml @@ -0,0 +1,60 @@ +
  • +
    +
    +

    @Model.Name

    +

    + @Model.Count tests +

    + + @if (Model.Passed > 0) { @Model.Passed } + @if (Model.Failed > 0) { @Model.Failed } + @if (Model.Skipped > 0) { @Model.Skipped } + @if (Model.Others > 0) { @Model.Others } + +
    +
    +
    +
    +
    +
    +

    @Model.Name

    + @if (Model.Passed > 0) { @Model.Passed passed } + @if (Model.Failed > 0) { @Model.Failed failed } + @if (Model.Skipped > 0) { @Model.Skipped skipped } + @if (Model.Others > 0) { @Model.Others others } +
    +
    +
    +
    + + + + + + + + + + @foreach (var test in Model.TestCollection) + { + + + + + + } + +
    StatusTimestampTestName
    +
    @test.Status
    +
    @test.StartTime.ToString("HH:mm:ss") + @test.Name + @if (test.Parent != null) + { +
    + @test.Parent.Name +
    + } +
    +
    +
    +
  • diff --git a/ExtentReports/Views/Html/Partials/Head.cshtml b/ExtentReports/Views/Html/Partials/Head.cshtml new file mode 100644 index 0000000..be06ddd --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Head.cshtml @@ -0,0 +1,9 @@ + + + + @Model.MasterConfig.GetValue("documentTitle") + + + + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/Log.cshtml b/ExtentReports/Views/Html/Partials/Log.cshtml new file mode 100644 index 0000000..af43f7b --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Log.cshtml @@ -0,0 +1,32 @@ +@using AventStack.ExtentReports.ViewDefs + + + + + + + + + @foreach (var log in Model.LogContext.All()) + { + + + + + + } + +
    StatusTimestampDetails
    @log.Timestamp.ToString("HH:mm:ss") + @if (log.HasException) + { + + } + else + { + @Raw(log.Details) + } + @if (log.HasScreenCapture) + { + @Raw(log.ScreenCaptureContext.FirstOrDefault().SourceIcon) + } +
    diff --git a/ExtentReports/Views/Html/Partials/Navbar.cshtml b/ExtentReports/Views/Html/Partials/Navbar.cshtml new file mode 100644 index 0000000..456f555 --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Navbar.cshtml @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/RecurseNodes.cshtml b/ExtentReports/Views/Html/Partials/RecurseNodes.cshtml new file mode 100644 index 0000000..1328c46 --- /dev/null +++ b/ExtentReports/Views/Html/Partials/RecurseNodes.cshtml @@ -0,0 +1,32 @@ +@if (Model.HasChildren) +{ +
    + @foreach (var node in Model.NodeContext.All()) + { +
    + + @if (node.HasLog) + { +
    +
    + @Include("Log", node) +
    +
    + } + @if (node.HasChildren) + { + @Include("RecurseNodes", node) + } +
    + } +
    +} \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/Scripts.cshtml b/ExtentReports/Views/Html/Partials/Scripts.cshtml new file mode 100644 index 0000000..e8f9a4a --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Scripts.cshtml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Partials/Sidenav.cshtml b/ExtentReports/Views/Html/Partials/Sidenav.cshtml new file mode 100644 index 0000000..aa9ad37 --- /dev/null +++ b/ExtentReports/Views/Html/Partials/Sidenav.cshtml @@ -0,0 +1,66 @@ +
    +
    + +
    +
    \ No newline at end of file diff --git a/ExtentReports/Views/Html/Tag.cshtml b/ExtentReports/Views/Html/Tag.cshtml new file mode 100644 index 0000000..c031364 --- /dev/null +++ b/ExtentReports/Views/Html/Tag.cshtml @@ -0,0 +1,49 @@ +@using RazorEngine +@using RazorEngine.Templating + + + +@Include("Head") + +
    +
    + @Include("Navbar") + @Include("Sidenav") +
    +
    +
    +
    + +
    +
      + @foreach (var category in Model.CategoryContext.Context) + { + @Include("AttributesView", category) + } +
    +
    +
    +
    +
    +
    +
    +
    +
    + @Include("Scripts") + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Author/Author.cshtml b/ExtentReports/Views/V3Html/Author/V3Author.cshtml similarity index 100% rename from ExtentReports/Views/Html/Author/Author.cshtml rename to ExtentReports/Views/V3Html/Author/V3Author.cshtml diff --git a/ExtentReports/Views/Html/Category/Category.cshtml b/ExtentReports/Views/V3Html/Category/V3Category.cshtml similarity index 100% rename from ExtentReports/Views/Html/Category/Category.cshtml rename to ExtentReports/Views/V3Html/Category/V3Category.cshtml diff --git a/ExtentReports/Views/Html/Dashboard/Dashboard.cshtml b/ExtentReports/Views/V3Html/Dashboard/V3Dashboard.cshtml similarity index 98% rename from ExtentReports/Views/Html/Dashboard/Dashboard.cshtml rename to ExtentReports/Views/V3Html/Dashboard/V3Dashboard.cshtml index 043280e..ef27b88 100644 --- a/ExtentReports/Views/Html/Dashboard/Dashboard.cshtml +++ b/ExtentReports/Views/V3Html/Dashboard/V3Dashboard.cshtml @@ -118,7 +118,7 @@ @context.Skipped @context.Others - @((context.Passed / @context.Count)*100)% + @((context.Passed / context.Count)*100)% } diff --git a/ExtentReports/Views/Html/Exception/Exception.cshtml b/ExtentReports/Views/V3Html/Exception/V3Exception.cshtml similarity index 100% rename from ExtentReports/Views/Html/Exception/Exception.cshtml rename to ExtentReports/Views/V3Html/Exception/V3Exception.cshtml diff --git a/ExtentReports/Views/V3Html/IV3HtmlMarker.cs b/ExtentReports/Views/V3Html/IV3HtmlMarker.cs new file mode 100644 index 0000000..66ab6f0 --- /dev/null +++ b/ExtentReports/Views/V3Html/IV3HtmlMarker.cs @@ -0,0 +1,6 @@ +namespace AventStack.ExtentReports.Views.V3Html +{ + internal interface IV3HtmlMarker + { + } +} diff --git a/ExtentReports/Views/Html/Test/Charts.cshtml b/ExtentReports/Views/V3Html/Test/V3Charts.cshtml similarity index 100% rename from ExtentReports/Views/Html/Test/Charts.cshtml rename to ExtentReports/Views/V3Html/Test/V3Charts.cshtml diff --git a/ExtentReports/Views/Html/Test/Test.cshtml b/ExtentReports/Views/V3Html/Test/V3Test.cshtml similarity index 99% rename from ExtentReports/Views/Html/Test/Test.cshtml rename to ExtentReports/Views/V3Html/Test/V3Test.cshtml index 1e3960c..154ae57 100644 --- a/ExtentReports/Views/Html/Test/Test.cshtml +++ b/ExtentReports/Views/V3Html/Test/V3Test.cshtml @@ -4,7 +4,6 @@ var bdd = false; if (Model.TestList.Count > 0) { - bdd = Model.TestList[0].IsBehaviorDrivenType || (Model.TestList[0].HasChildren && Model.TestList[0].NodeContext.FirstOrDefault().IsBehaviorDrivenType); } } @@ -95,7 +94,7 @@ - @Include("Charts") + @Include("V3Charts")
      diff --git a/ExtentReports/Views/Html/TestRunner/Logs.cshtml b/ExtentReports/Views/V3Html/TestRunner/V3Logs.cshtml similarity index 100% rename from ExtentReports/Views/Html/TestRunner/Logs.cshtml rename to ExtentReports/Views/V3Html/TestRunner/V3Logs.cshtml diff --git a/ExtentReports/Views/Html/Head.cshtml b/ExtentReports/Views/V3Html/V3Head.cshtml similarity index 100% rename from ExtentReports/Views/Html/Head.cshtml rename to ExtentReports/Views/V3Html/V3Head.cshtml diff --git a/ExtentReports/Views/V3Html/V3Index.cshtml b/ExtentReports/Views/V3Html/V3Index.cshtml new file mode 100644 index 0000000..0221d8d --- /dev/null +++ b/ExtentReports/Views/V3Html/V3Index.cshtml @@ -0,0 +1,84 @@ +@using RazorEngine +@using RazorEngine.Templating + + + + + @Include("V3Head") + + +
      + desktop_windows +
      + + @Include("V3Nav") + + +
      + @Include("V3Test") + @Include("V3Author") + @Include("V3Category") + @Include("V3Exception") + @Include("V3Dashboard") + @Include("V3Logs") +
      + + + @if (Model.MasterConfig.GetValue("enableTimeline") == "true") + { + var json = ""; + for (int ix = 0; ix < Model.TestList.Count; ix++) { + json += "\"" + Model.TestList[ix].Name + "\"" + ":" + Model.TestList[ix].RunDuration.TotalSeconds; + if (ix != Model.TestList.Count-1) { + json += ","; + } + } + + } + + @if (Model.MasterConfig.GetValue("chartVisibleOnOpen") == "false") + { + + } + + + \ No newline at end of file diff --git a/ExtentReports/Views/Html/Nav.cshtml b/ExtentReports/Views/V3Html/V3Nav.cshtml similarity index 100% rename from ExtentReports/Views/Html/Nav.cshtml rename to ExtentReports/Views/V3Html/V3Nav.cshtml