Catching up with Allure. Part 1: framework integration

Several months ago I noticed that lots of my friends have no idea what Allure is and how it can be useful in their day-to-day work. I’m aimed at fixing this blooper, especially after the 2nd generation of this framework has been released recently.

So, what is Allure? It’s a light-weight framework for generating reports for automated tests. It is evolving actively and bringing us the support of new features quite often. In order to understand exactly what Allure can (and cannot) do, I’ll list the main features here:

  • support of different languages: Java, Python, JavaScript, Ruby, Groovy, PHP, .NET and Scala. It’s impressive! However, in the case of NUnit, we can’t use it with version 3.x because there is no Allure adapter for it. But we can still use NUnit 2.x.;
  • several ways of the report generation: through the command line, as a plugin for CI systems (Jenkins, TeamCity) or via build tools;
  • nice look of a generated report (it’s really not ugly, check this example). We are allowed to add info about a test environment, keep test runs history (CI feature), manage different report graphs (time, severity, behavior, etc.) and tests (categories, packages);
  • customizing test cases in a report. Actually, this part is the most interesting and valuable one because Allure allows us to pass lots of information about a test to the report (steps, attach screenshots and different files, bug tracker links to issues, links to a test case management system, specify severity, features, stories).

As you see, it sounds promising. But all the above-mentioned doesn’t help us too much in understanding how we can use Allure in our test frameworks, how we can generate a necessary report and where we can actually see it. That’s why I decided to start these series of articles, and this post is the first one. Here goes!

Challenge for this post

To prepare a Java test project structure with Allure configured for generating files necessary for the report creation.

First of all, let’s define the scope for the next couple of articles! I am going to write several functional tests for the international Amazon website. However, I will be using Selenide framework instead of pure Selenium WebDriver. As a unit test framework, I’d like to choose TestNG because it’s my favorite one for now. And, of course, Allure framework will be used for generating reports after every test run. Everything will be managed by Maven build tool. That’s the main idea.

 

Step 1.

First of all, let’s create a new Maven Java project in the IDE (I’m using Intellij IDEA). When the project is ready, we can edit the pom.xml and add necessary dependencies:

As you see, I added the main components necessary for writing tests and associated data: Selenide, Allure and WebDriverManager. The last one is needed for resolving browsers drivers binaries.

Now we have everything ready for writing tests but not for creating Allure data files necessary for the report generation stage. This is gonna be fixed in the next step…

 

Step 2.

Allure report is built from JSON files and attachment files that are generated after each test run. In order to provide these files, we should modify pom.xml, add several plugins and dependencies to the <build>  section:

The key points here are:

  • AspectJ Weaver dependency which is used by Allure;
  • Maven Surefire plugin and its allure.results.directory property. The value of this property points Maven Surefire plugin to the location where the generate Allure JSON files should be saved. In the next article, we will be using this folder for the report generation step.

So, since now on everything is ready for writing tests and executing them. That’s what I’m going to do in the next article. Stay in tune!

Like this post?

Subscribe to updates from my blog, if you don't want to miss more interesting future posts and materials

Please check your email and confirm subscription

Pin It on Pinterest

Share This