How to make use of Extent Reports in Seleniium Java in your code in a meaningful way?

397 Views Asked by At

I have a Maven project and currently use the below Extent report version:

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>4.1.5</version>
</dependency>

I have Extent Reports up and running, but wonder how we are to use them in the real world.

For example, I have managed to use an Assertion in the following way:

try {
    Assert.assertEquals(cart.getTotalAmount().getText(), "$45.24");
    test.pass("amount correct");
} catch (AssertionError e) {
    Assert.fail();
    test.fail(e);
}

Which works fine. But is it common to embed a number of 'if statements' to output .PASS or .FAIL results in our code or is this approach not recommended?

I'm trying to understand to what degree we should be reporting and if it's common to use the IF/ELSE approach to output to the reports. The problem I see with this approach is that our code would become embedded with a number of IF/ELSE statements - which makes me question whether this is right or not?

1

There are 1 best solutions below

2
On

Good question .. . Extent report is just a reporting library which will help you get an html report for your test case executed .

And to what degree you should be reporting depends upon what type of test case scenario you are trying to automate .

It's not always that you have to write if else block with assertion in it . But most important thing is your automation script should be capable of catching out changes for example -

For a checkout automation scenario you will be automating whole checkout from adding product to cart go to my cart page and.then proceed with a checkout .

But other things you have to implement in your script is that the price of the product should be same across all pages . Should be able to validate that you are getting a success message on adding product to cart or validating a order success message whether you are getting a order number or not. all such things needs to be taken care of while writing scripts for such scenario .

Just writing scripts to click the elements is not enough I have seen scripts written were all regression test scenarios are passed but still on production customer finds lot of defects such automation testing is of no use if customer is finding more defects than test automation engineers .

Try to test and validate every detail as much as you can in scripts to increase quality of product . Good luck & Happy Testing :)