Extent Reports Log Generation in C#

Extent Reports Log Generation will discuss about how to generate log steps in the Extent Reports. While running the test suite user want to log some information about the execution in the report. This information will help the user to understand the test step execution flow and any failures during the test suite execution.
By using Extent Reports we can generate logs in the HTML report. For this we need use the Log() method of the ExtentTest Class. By using this method not only log the step information, we can provide the Pass, Fail and Skip information of the particular test case. To log the information we need to use the LogStatus.Info as first parameter in the Log() method. And we need to use LogStatus.Pass for the passed test case and LogStatus.Fail for the failed test cases.
Below is the methods related for generating step logs in the report:
using RelevantCodes.ExtentReports;
public static ExtentTest test
public static ExtentReports extent;
 test = extent.StartTest("Test Case Name");
test.Log(LogStatus.Pass, "Test Case Name is Passed"); 
test.Log(LogStatus.Fail, "Test Case Name is Failed");
extent.EndTest(test);    
extent.Flush();

Finally, you may get a test report like following (The sample is the last case at left-bottom):






0 comments:

Post a Comment