Skip to content

Commit c75b09b

Browse files
committed
Create base directory in BasicFileReporter
1 parent 697ce0f commit c75b09b

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

ExtentReports/ExtentReports.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<DebugSymbols>true</DebugSymbols>
1919
<DebugType>full</DebugType>
2020
<Optimize>false</Optimize>
21-
<OutputPath>bin\</OutputPath>
21+
<OutputPath>bin\Debug\</OutputPath>
2222
<DefineConstants>DEBUG;TRACE</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
@@ -154,6 +154,7 @@
154154
<Compile Include="Reporter\ExtentV3HtmlReporter.cs" />
155155
<Compile Include="Reporter\ExtentLoggerReporter.cs" />
156156
<Compile Include="Reporter\TemplateEngine\RazorEngineManager.cs" />
157+
<Compile Include="Reporter\TemplateEngine\TemplateLoadService.cs" />
157158
<Compile Include="Reporter\TemplateInfo.cs" />
158159
<Compile Include="Core\ReportStatusStats.cs" />
159160
<Compile Include="Status.cs" />
@@ -173,6 +174,7 @@
173174
<Compile Include="Views\Commons\ICommonsMarker.cs" />
174175
<Compile Include="Views\Html\IHtml2Marker.cs" />
175176
<EmbeddedResource Include="Views\Html\Partials\Attributes.cshtml" />
177+
<Compile Include="Views\IViewsMarker.cs" />
176178
<Compile Include="Views\V3Html\IV3HtmlMarker.cs" />
177179
<Compile Include="Views\Logger\ILoggerMarker.cs" />
178180
</ItemGroup>

ExtentReports/Reporter/BasicFileReporter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ protected BasicFileReporter(string filePath)
4949
SavePath = filePath;
5050
FolderSavePath = Path.GetDirectoryName(filePath);
5151
FolderSavePath = string.IsNullOrEmpty(FolderSavePath) ? "./" : FolderSavePath;
52+
53+
if (!Directory.Exists(FolderSavePath))
54+
{
55+
Directory.CreateDirectory(FolderSavePath);
56+
}
5257
}
5358

5459
protected void Initialize(BasicFileConfiguration userConfig)

ExtentReports/Reporter/ExtentHtmlReporter.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
namespace AventStack.ExtentReports.Reporter
1212
{
13-
/// <summary>
14-
/// The ExtentHtmlReporter creates a rich standalone HTML file. It allows several configuration options
15-
/// via the <code>Configuration()</code> method.
16-
/// </summary>
1713
public class ExtentHtmlReporter : BasicFileReporter
1814
{
1915
public new string ReporterName => "html";
@@ -33,8 +29,6 @@ public override void Flush(ReportAggregates reportAggregates)
3329
{
3430
base.Flush(reportAggregates);
3531

36-
Directory.CreateDirectory(FolderSavePath);
37-
3832
var source = RazorEngineManager.Instance.Razor.RunCompile("Index", typeof(ExtentHtmlReporter), this);
3933
File.WriteAllText(Path.Combine(FolderSavePath, "index.html"), source);
4034
source = RazorEngineManager.Instance.Razor.RunCompile("Dashboard", typeof(ExtentHtmlReporter), this);

ExtentReports/Reporter/ExtentLoggerReporter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public override void Flush(ReportAggregates reportAggregates)
3030
{
3131
base.Flush(reportAggregates);
3232

33-
Directory.CreateDirectory(SavePath);
34-
3533
var source = RazorEngineManager.Instance.Razor.RunCompile("LoggerTest", typeof(ExtentLoggerReporter), this);
3634
File.WriteAllText(SavePath + "Index.html", source);
3735
source = RazorEngineManager.Instance.Razor.RunCompile("LoggerDashboard", typeof(ExtentLoggerReporter), this);

ExtentReports/Reporter/ExtentV3HtmlReporter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public ExtentV3HtmlReporter(string filePath) : base(filePath)
3131

3232
public override void Flush(ReportAggregates reportAggregates)
3333
{
34-
Directory.CreateDirectory(Path.GetDirectoryName(SavePath));
3534
base.Flush(reportAggregates);
3635
var source = RazorEngineManager.Instance.Razor.RunCompile("V3Index", typeof(ExtentV3HtmlReporter), this);
3736
File.WriteAllText(SavePath, source);

ExtentReports/Reporter/TemplateEngine/TemplateLoadService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public static void LoadTemplate<T>(string[] templates) where T : IViewsMarker
2121
using (var resourceStream = typeof(T).Assembly.GetManifestResourceStream(resourceName))
2222
{
2323
using (var reader = new StreamReader(resourceStream))
24-
2524
{
2625
if (resourceStream != null)
2726
{

0 commit comments

Comments
 (0)