Skip to content

Commit

Permalink
#23 : can generate html report
Browse files Browse the repository at this point in the history
  • Loading branch information
huaxing-yuan committed Jun 8, 2023
1 parent 79a0111 commit 67c3e97
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
30 changes: 18 additions & 12 deletions src/AxaFrance.WebEngine.Doc/articles/webrunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,40 +68,46 @@ WebRunner.exe "-a:AppProject.dll" "-data:Data.xml" "-env:Staging.xml" -platform:
> Some parameters can be provided in the configuration file `appsettings.json` for C# and `application-properties.yml` for JAVA. please refer to [Test Configuration](appsettings.md)
### Commun parameters
##### -browser:\<browser>
#### -browser:\<browser>
Specifies the browser on which to run test. see: <xref:AxaFrance.WebEngine.BrowserType>.
##### -platform:\<platform>
#### -platform:\<platform>
Specifies The platform for test execution: see: <xref:AxaFrance.WebEngine.Platform>. Default value is `Windows`.
##### -outputDir:\<outputFolder>
#### -outputDir:\<outputFolder>
Specifies the folder to store output of test execution and test report. This parameter is can be defined in `appsetting.json` for C# and `application-properties.yml` for JAVA.
##### -m

#### -m
Specifies the manual debug mode. Use this mode for debugging test scenarios locally. When the test is failed test will pause for manual intervention before clean-up process.
##### -junit:\<junitPath>

#### -junit:\<junit-report-path>
In additional of default XML report, generates a JUnit 2.6 compliant test report. Useful to publish test result to a Continuous Integration Platform
##### -showReport

#### -html:\<html-report-path>
In additional of default XML report, generates a HTML test report. Test report will be generated in the given folder. HTML report contains also css, javascript and screenshot files. If you want the share the report, you have to copy the whole folder.

#### -showReport
Launches `Report Viewer` after test execution.

### Parameters for Mobile testing
To run tests on Mobile device, `-platform`, you should specify the following arguments `Android` or `iOS`.

##### -grid:\<gridUrl>
#### -grid:\<gridUrl>
Indicates the Selenium Grid to connect to device cloud. Default value is `http://localhost:4723/wd/hub` for local Appium Server
If you are using cloud-based device cloud, please refer to service providers documentation.
If the argument is provided, option `desktopGrid` will be automatically set to `true`

##### -desktopGrid
#### -desktopGrid
This option activates the usage of Selenium Grid for Web Desktop tests. If the value is false, the framework only use selenium grid for mobile based tests.

##### -username:\<username>
#### -username:\<username>
Indicates the username to be used for Selenium Grid authentication.

##### -password:\<password>
#### -password:\<password>
Indicates the password to be used for Selenium Grid authentication.

##### -device:\<deviceName>
#### -device:\<deviceName>
Indicates the device name for device selection. for example: `iPhone Xs`, `Huawei P30`. Refers your cloud provider.

##### -osVersion:\<version>
#### -osVersion:\<version>
Indicate the version of the OS for device selection. for example: `14.1`, `9.0`. Refers your cloud provider.

### Where to find WebRunner package?
Expand Down
10 changes: 10 additions & 0 deletions src/AxaFrance.WebEngine.Runner/ParameterParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ private static void ParseReportOption(string[] args, Settings s)
DebugLogger.WriteLine("[CONFIG] Generated JUnit Report: " + s.ReportSettings.JUnitReportPath);
}

const string argHtml = "-html:";
string html = args.FirstOrDefault(x => x.StartsWith(argHtml, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(html))
{
string outputPath = html.Replace(arg, string.Empty);
outputPath = outputPath.TrimEnd('\"');
s.ReportSettings.HtmlReport = true;
s.ReportSettings.HtmlReportPath = outputPath;
DebugLogger.WriteLine("[CONFIG] Generated HTML Report: " + s.ReportSettings.HtmlReportPath);
}
}


Expand Down
8 changes: 7 additions & 1 deletion src/AxaFrance.WebEngine.Runner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public static void Main(string[] args)
DebugLogger.WriteLine("JUnit Report Generated: " + jReport);
}

if (settings.ReportSettings.HtmlReport)
{
var htmlReport = ReportHelper.GenerateHtmlReport(result, settings.DataSourceName, settings.ReportSettings.HtmlReportPath);
DebugLogger.WriteLine("HTML Report Generated: " + htmlReport);
}

var reportPath = result.SaveAs(settings.LogDir, logFileName, false);
DebugLogger.WriteLine("Report Generated: " + reportPath);
try
Expand All @@ -68,7 +74,7 @@ public static void Main(string[] args)
private static void ShowHelpMessage()
{
Console.WriteLine("Parameter error.");
Console.WriteLine("Please refers to documentation: https://xxx.xxx.xxx/articles/webrunner.html");
Console.WriteLine("Please refers to documentation: https://axafrance.github.io/webengine-dotnet/articles/webrunner.html");
}

private static void Encrypt(string data)
Expand Down
10 changes: 10 additions & 0 deletions src/AxaFrance.WebEngine/ReportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public class ReportSettings
/// The location of the NUnit report. (default location will be <see cref="Settings.LogDir"/>)
/// </summary>
public string NUnitReportPath { get; set; }

/// <summary>
/// Indicates if a HTML report should be generated after test execution
/// </summary>
public bool HtmlReport { get; set; }

/// <summary>
/// The location of the HTML report. (default location will be <see cref="Settings.LogDir"/>)
/// </summary>
public string HtmlReportPath { get; set; }
}

}

0 comments on commit 67c3e97

Please sign in to comment.