Showing test results in Report

Gradle will build a test result automatically when you run script by gradle clean test command.

You can find it this location:

PROJECT_ROOT_FOLDER>build>reports>tests>test>index.html

Open the index.html file and you will see the test result.

But this report looks like ugly. So we will build a nice report UI by Allure.

Open the build.gradle file and import Allure package by adding this command:

implementation group: 'io.qameta.allure', name: 'allure-testng', version: '2.17.2'

Now download allure zip from here and extract and put it on this location: C:\Program Files\Java

Then set the allure bin path to environment variable.

Now run your project again:

gradle clean test

Then generate allure by this command:

allure generate allure-results --clean -o allure-report

Finally hit this command to view report:

allure serve allure-results

Troubleshooting

In most of the cases after giving allure report generation command, there is showing an error as:

‘allure’ is not recognized as an internal or external command, operable program or batch file

It will happen when allure path is not set to the environment variable.

Now just type following command:

allure --version
Output> 2.13.8

It will see the version of the allure and will not show the error anymore.

If you want to run your test in headless mode, then just edit BagePage.java like this:

@BeforeClass
    public void setUp() throws IOException {
        System.setProperty("webdriver.gecko.driver", "./src/test/resources/geckodriver.exe");
        FirefoxOptions ops=new FirefoxOptions();
        ops.addArguments("-headless");
        driver = new FirefoxDriver(ops);
        driver.manage().window().maximize();
        wait = new WebDriverWait(driver,5);
    }

Now run again your test case and you will see no browser is started visually. Test case will run in background and after finishing all test cases, it will show the test result.

Here is the full project:
https://github.com/salmansrabon/selenium-java-demo-project

about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

2 Comments on "Showing test results in Report"

    Hello!
    Unfortunately “allure –version” (expected response: Output> 2.13.8) does not resolve the issue of “‘allure’ is not recognized as an internal or external command, operable program or batch file”.
    Could you please clarify the details? Did you edit any settings or something else in Intellij Idea?

Leave a Reply

Your email address will not be published. Required fields are marked *