> Text report

> Allure report


First of all, please think twice: probably you don’t need any specific reports.

Both Gradle and Maven already generate good enough test report which includes all the errors.
When a test fails, Selenide already generates a detailed error message (including screenshot and html of a page). Typically it’s enough to understand why the test failed:

Element should be hidden {#gameWin}
Element: '<img class="gameOver" id="gameWin" src="img/thumbs-up.jpeg"></img>'

Screenshot: file:/.../hangman/build/reports/tests/1510751914648.0.png
Page source: file:/.../hangman/build/reports/tests/1510751914648.0.html
Timeout: 4 s.

If you still want to get reports, we can suggest two options: “Text report” and “Allure report”.

1. Text report

It’s a simple report built in Selenide which shows all steps that were performed during the test:

|Element               |Subject                                      |Status  |ms.       |
|open                  |http://localhost:2070/                       |PASSED  |4669      |
|open                  |http://localhost:2070/fakeLogin?username=bob |PASSED  |1324      |
|By.linkText: Quicky   |click()                                      |PASSED  |793       |
|#btn-message-reply    |click()                                      |PASSED  |1002      |
| message.text |should be(focused)                           |PASSED  |57        |
| message.text |should have(text 'long thread')              |PASSED  |47        |
| message.text |set value(Hello world!)                      |PASSED  |69        |
|#send-button          |click()                                      |PASSED  |1051      |
|.alert-success        |should be(visible)                           |PASSED  |71        |

It looks simple, but contains all the needed information.
To enable such a report, you need to

  1. Setup slf4j in your project (slf4j is de-facto a standard logging tool in Java world).
  2. Add extensions/rule/listener as shown below.

For JUnit 5:

  import com.codeborne.selenide.junit5.TextReportExtension;

  public class MyTest {
    // ...

For JUnit 4:

import com.codeborne.selenide.junit.TextReport;

public class MyTest {
  public TextReport textReport = new TextReport();

  // ...

For TestNG:

import com.codeborne.selenide.testng.TextReport;

@Listeners({ TextReport.class})
public class MyTest {
  // ...

2. Allure report

QA engineers often want to generate “beautiful” reports. It’s for managers, they say.
I am rather skeptical about those reports. I think managers don’t really read those reports. Think twice before you spend your time on “beautifying” reports.

If you still insist, you can setup Allure. It’s a popular open-source reporting library from Qameta Software company.
It has built-in integration with Selenide. And yes, its reports look really nice. :)

You will need to

  1. Add dependency io.qameta.allure:allure-selenide:2.21.0 (or higher) to your project.
  2. Add a line in the beginning of your tests:
    static void setupAllureReports() {
      SelenideLogger.addListener("AllureSelenide", new AllureSelenide());

       // or for fine-tuning:
      SelenideLogger.addListener("AllureSelenide", new AllureSelenide()

See a sample project Selenide+Allure

P.S. But please, PLEASE don’t take BDD for nice reports! BDD is not intended for reports. BDD is a development process. BDD will only create more problem for you if you only apply it technically, without changing the process.