Trgan Report Csharp Tutorial
This guide walks through all the core features TrganReport provides for generating modular, branded HTML reports in C#.
Create and Generate Report
To get started, install TrganReport via Visual Studio’s NuGet package manager or by adding the following to your .csproj
file:
1 2 3 |
|
1 |
|
Initialize a report by creating a TrganHtmlReport object and specifying the output path and filename:
2 |
|
Organize with Containers and Tests
You can create TrganContainer or TrganTest objects concurrently. For module-based reports, use containers to group related tests:
3 |
|
Both TrganContainer and TrganTest accept an optional string[] categories parameter, which helps visualize tags in the Execution Status Table under the Category column.
Create tests within a container:
4 5 6 |
|
Update test status using:
test.Pass();
test.Fail();
test.Skip();
test.Log(status);
Add Steps and BDD Keywords
You can add steps to a test to mark checkpoints or trace actions:
7 8 9 |
|
For BDD-style reports, use Gherkin keywords:
7 8 9 |
|
View Example-3: Normal Test and BDD Test
Create and Update Steps Separately
You can split step creation and status updates:
10 11 12 13 14 15 16 17 18 19 20 |
|
After all steps are completed, generate the report:
19 |
|
View Example-1: container based report
View Example-2: test based report
Adding trace logs to a step
Trace logs act as sub-checkpoints within a step. Use Write() to log messages:
1 2 3 |
|
View Example-4: trace logs in step
Each log includes a timestamp by default. The Write()method accepts:
-
A string message
-
An optional Screenshot
-
A bool timeStamp flag to disable timestamp
Valid Combinations
step.Write("entered username");
step.Write(screenshot);
step.Write("entered username",timeStamp:false);
step.Write(screenshot,timeStamp:false);
step.Write("entered username",screenshot);
step.Write("entered username",screenshot,timeStamp:false);
Upcomings
- Screenshot attachments
- TrganTable