### Installing Allure on Windows using Scoop Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This command installs Allure Report on Windows via Scoop, a command-line installer. Users must have Scoop installed beforehand to execute this command successfully. ```shell script scoop install allure ``` -------------------------------- ### Verifying Allure Report Installation Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This snippet shows how to confirm that Allure Report has been successfully installed and is accessible from the command line. Executing allure --version displays the installed version number. ```shell script $ allure --version 2.0.1 ``` -------------------------------- ### Installing Allure on macOS with Homebrew Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This command demonstrates how to install Allure Report on macOS using Homebrew, a popular package manager. It simplifies the installation process by fetching and installing the necessary files. ```shell script brew install allure ``` -------------------------------- ### Installing Allure on Debian-based Linux Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This snippet provides commands for installing Allure Report on Debian-based Linux distributions. It involves adding the Allure PPA repository, updating the package list, and then installing the allure package using apt-get. ```shell script sudo apt-add-repository ppa:qameta/allure sudo apt-get update sudo apt-get install allure ``` -------------------------------- ### Updating Allure on Windows using Scoop Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This command updates an existing Allure Report installation on Windows using the Scoop package manager. It should be run after checking for new versions with checkver.ps1. ```shell script scoop update allure ``` -------------------------------- ### Generating and Serving Allure Report Locally Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This command generates an Allure Report from test results (e.g., Surefire XML reports) located in a specified path. It then starts a local Jetty server to serve the report and automatically opens it in the default web browser. ```shell script allure serve /home/path/to/project/target/surefire-reports/ ``` -------------------------------- ### Checking for Allure Updates with Scoop on Windows Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/quickstart.md This PowerShell command, executed from the Scoop installation directory, checks for newer versions of Allure and updates its manifest file. It's a prerequisite step before performing an actual update. ```PowerShell \\bin\\checkver.ps1 allure -u ``` -------------------------------- ### Installing Allure CLI on Debian-based Systems Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/commandline.md This set of commands installs the Allure command-line interface on Debian-based Linux distributions. It adds the Allure PPA repository, updates the package list, and then installs the 'allure-commandline' package, providing the 'allure' command. ```shell script $ sudo apt-add-repository ppa:yandex-qatools/allure-framework $ sudo apt-get update $ sudo apt-get install allure-commandline ``` -------------------------------- ### Installing Allure CLI on macOS using Homebrew Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/commandline.md This command sequence installs the Allure command-line interface on macOS. It first taps the official Allure Homebrew repository and then installs the 'allure' package, making the 'allure' command available system-wide. ```shell script $ brew tap qameta/allure $ brew install allure ``` -------------------------------- ### Starting Karma with Allure Reporter via CLI (Shell) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/karma.md This shell command demonstrates how to start Karma and specify reporters directly via the command-line interface. The `--reporters` flag allows you to pass a comma-separated list of reporter names, such as 'allure' and 'dots', overriding any configuration in `karma.conf.js`. ```Shell karma start --reporters allure,dots ``` -------------------------------- ### Configuring Allure Commandline via System Groovy in Jenkins Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/jenkins.md This Groovy script automates the installation and configuration of a specific version (2.6.0) of the Allure Commandline tool in Jenkins's "Global Tool Configuration". It programmatically creates an AllureCommandlineInstaller and an AllureCommandlineInstallation, then sets and saves this installation using the Jenkins descriptor. This method is an alternative to manual configuration through the Jenkins UI. ```groovy import ru.yandex.qatools.allure.jenkins.tools.* import hudson.tools.InstallSourceProperty import hudson.tools.ToolProperty import hudson.tools.ToolPropertyDescriptor import hudson.util.DescribableList def isp = new InstallSourceProperty() def autoInstaller = new AllureCommandlineInstaller("2.6.0") isp.installers.add(autoInstaller) def proplist = new DescribableList, ToolPropertyDescriptor>() proplist.add(isp) def installation = new AllureCommandlineInstallation("allure260", "", proplist) def allureDesc = jenkins.model.Jenkins.instance.getExtensionList(AllureCommandlineInstallation.DescriptorImpl.class)[0] allureDesc.setInstallations(installation) allureDesc.save() ``` -------------------------------- ### Installing Karma Allure Reporter via npm (Shell) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/karma.md This command demonstrates how to install `karma-allure-reporter` using npm. The `--save-dev` flag ensures that the package is added to the `devDependencies` section of your `package.json` file, indicating it's a development-time dependency. ```Shell npm install karma-allure-reporter --save-dev ``` -------------------------------- ### Executing Bundle for Allure Cucumber Installation Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Runs the `bundle` command to install the gems specified in your Gemfile, including `allure-cucumber`. ```Shell $ bundle ``` -------------------------------- ### Installing Allure Cucumber Gem Directly Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Installs the `allure-cucumber` gem globally or for the current user using the `gem install` command. ```Shell $ gem install allure-cucumber ``` -------------------------------- ### Installing Allure Reporter for Mocha via npm Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/mocha.md This command installs the `mocha-allure-reporter` package using npm, making it available for use with the Mocha testing framework. It is a prerequisite for generating Allure reports from Mocha test runs. ```Shell npm install mocha-allure-reporter ``` -------------------------------- ### Installing Allure Behave Integration Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/behave.md This command installs the `allure-behave` package using pip, enabling Allure integration with the Behave framework. It is a prerequisite for using Allure as an external formatter. ```Shell $ pip install allure-behave ``` -------------------------------- ### Generating Allure Report with Maven Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/maven.md Generates the Allure report into the `target/site/allure-maven/index.html` directory. This command creates a static report without starting a web server, suitable for CI/CD pipelines or static hosting. ```bash mvn allure:report ``` -------------------------------- ### Generating Allure Report from Junit Results Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/existing.md This command is used to generate an Allure report from Junit test results. When executed in a directory containing Junit XML files, it processes them and creates an Allure report. ```Shell allure generate ``` -------------------------------- ### Serving Allure Report with Maven Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/maven.md Generates an Allure report into a temporary folder and starts a web server to display the results. This command is useful for quickly reviewing reports locally, and the server timeout can be configured via the `allure.serve.timeout` system property. ```bash mvn allure:serve ``` -------------------------------- ### Installing Allure Pytest Adapter Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This command installs the allure-pytest package and its dependencies using pip, enabling the generation of report data compatible with Allure 2. It's recommended to uninstall previous versions of pytest-allure-adaptor if upgrading. ```Shell pip install allure-pytest ``` -------------------------------- ### Serving Allure HTML Report with Maven Jetty Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/cucumber.md This shell command starts a Jetty server via Maven to serve the generated Allure HTML reports. It allows specifying a custom port (e.g., 1234) for accessing the reports locally. ```shell mvn jetty:run -Djetty.port=1234 ``` -------------------------------- ### Example Allure Test Result JSON Structure Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This JSON snippet illustrates the structure of a typical Allure test result for a parameterized test. It shows how test case arguments are captured in the 'parameters' section, along with other details like 'uuid', 'fullName', 'name', 'status', 'stage', 'start', and 'stop' timestamps. This structure serves as the input for custom Allure plugins. ```json { "uuid":"0edd28b1-3c7f-4593-8dda-db9aa004891f", "fullName":"io.qameta.allure.animals.AnimalsTest.angryCat", "name":"angryCat", "status":"passed", "stage":"finished", "start":1495467840415, "stop":1495467840416, "parameters":[ { "name":"arg0", "value":"Hiss!" } ] } ``` -------------------------------- ### Adding Display Name to TestNG Methods Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This Java code demonstrates how to use the `description` property of the `@Test` and `@BeforeMethod` annotations in TestNG. This property allows developers to provide human-readable names for test methods and setup methods, which Allure will then display prominently in the generated report. ```Java package my.company.tests; import org.testng.annotations.Test; public class MyTests { @BeforeMethod(description = "Configure something before test") public void setUp() { //... } @Test(description = "Human-readable test name") public void testSomething() throws Exception { //... } } ``` -------------------------------- ### Installing Allure Maven Plugin Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/maven.md Adds the Allure Maven plugin to the project's `pom.xml` build section, enabling Allure report generation during the Maven build process. This snippet specifies the plugin's `groupId`, `artifactId`, and `version`. ```xml ... io.qameta.allure allure-maven 2.8 ... ``` -------------------------------- ### Example Allure Cucumber Tag Usage in Scenario Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Illustrates how default Allure tags for severity, issue tracking, and test management are applied to a Cucumber scenario. ```Gherkin @SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901 Scenario: Leave First Name Blank When I register an account without a first name Then exactly (1) [validation_error] should be visible ``` -------------------------------- ### Configuring Allure Reporter for Jasmine2 Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/jasmine.md This snippet demonstrates how to configure the 'jasmine-allure-reporter' in a Jasmine2 test setup. It requires adding the library and then using 'jasmine.getEnv().addReporter' to register the Allure reporter, specifying 'allure-results' as the directory for output files. ```javascript // conf.js var AllureReporter = require('jasmine-allure-reporter'); jasmine.getEnv().addReporter(new AllureReporter({ resultsDir: 'allure-results' })); ``` -------------------------------- ### Defining RSpec Tests with Allure Annotations and Steps Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/rspec.md This comprehensive example demonstrates how to write RSpec tests using Allure annotations like 'feature', 'severity', 'story', and 'testId'. It also shows how to define granular test steps and attach files (e.g., screenshots) within those steps for detailed reporting. ```Ruby describe MySpec, :feature => "Some feature", :severity => :normal do before(:step) do |s| puts "Before step #{s.current_step}" end it "should be critical", :story => "First story", :severity => :critical, :testId => 99 do "string".should == "string" end it "should be steps enabled", :story => ["First story", "Second story"], :testId => 31 do |e| e.step "step1" do |s| s.attach_file "screenshot1", take_screenshot_as_file end e.step "step2" do 5.should be > 0 end e.step "step3" do 0.should == 0 end e.attach_file "screenshot2", take_screenshot_as_file end end ``` -------------------------------- ### Example Custom Allure Cucumber Tag Usage in Scenario Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Demonstrates the application of custom Allure tags for severity, issue tracking, and test management within a Cucumber scenario. ```Gherkin @URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901 Scenario: Leave First Name Blank When I register an account without a first name Then exactly (1) [validation_error] should be visible ``` -------------------------------- ### Running Protractor Screenshot Tests Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/cucumber.md This shell command executes Protractor tests, specifically a screenshot test, using its local binary and a configuration file. It requires `protractor` and `protractor-cucumber-framework` to be installed. ```shell ./node_modules/protractor/bin/protractor miscellaneous/protractorScreenshot/conf.js ``` -------------------------------- ### Example Custom Plugin Data JSON (myplugindata.json) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This JSON snippet represents the 'myplugindata.json' file generated by the 'aggregate' method of the 'MyPlugin' class. It shows extracted data, such as 'sounds' and 'name', for various test results, intended to be displayed on a new custom tab in the Allure report. ```json [ { "sounds" : [ "Growl!", "Hiss!" ], "name" : "angryCat" }, { "sounds" : [ "Oink!", "Meow!" ], "name" : "hungryCat" }, { "sounds" : [ "Bark!", "Woof!", "Moo!" ], "name" : "bigDog" } ] ``` -------------------------------- ### Allure Steps with Title Placeholders in Python Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This example illustrates how to use placeholders in Allure step titles to dynamically include positional and keyword arguments. The `@allure.step` decorator accepts a format string, allowing for more descriptive and context-rich step names in the report. ```python import allure @allure.step('Step with placeholders in the title, positional: "{0}", keyword: "{key}"') def step_with_title_placeholders(arg1, key=None): pass def test_steps_with_placeholders(): step_with_title_placeholders(1, key='something') step_with_title_placeholders(2) step_with_title_placeholders(3, 'anything') ``` -------------------------------- ### Configuring Custom Logo Plugin in Allure (YAML) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/existing.md This YAML configuration defines the `custom-logo` plugin for Allure. It sets the plugin ID, name, and description, and specifies `styles.css` as a CSS file to be included, which is used to override the default Allure logo. ```YAML id: custom-logo name: Custom logo aggregator description: The aggregator replaces default Allure logo with a custom one cssFiles: - styles.css ``` -------------------------------- ### Declaring Karma Allure Reporter as DevDependency (JSON) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/karma.md This JSON snippet shows how to declare `karma-allure-reporter` as a development dependency in your `package.json` file. It specifies the required versions for both `karma` and `karma-allure-reporter` to ensure compatibility and proper installation. ```JSON { "devDependencies": { "karma": "~0.10", "karma-allure-reporter": "~1.0.0" } } ``` -------------------------------- ### Aggregating Test Results by Feature and Story in Allure (Java) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/existing.md This Java method, `getGroups`, is part of the `BehaviorsPlugin` and is responsible for classifying `TestResult` objects into groups based on `FEATURE` and `STORY` labels. It uses `TreeGroup.allByLabel` to create groups, which determines how test results are organized in the `behaviors.json` file. ```Java @Override protected List getGroups(final TestResult result) { return Arrays.asList( TreeGroup.allByLabel(result, LabelName.FEATURE, DEFAULT_FEATURE), TreeGroup.allByLabel(result, LabelName.STORY, DEFAULT_STORY) ); } ``` -------------------------------- ### Adding Behaviors Tab and Widget to Allure Report (JavaScript) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/existing.md This JavaScript code defines how the Behaviors plugin integrates into the Allure report UI. It uses `allure.api.addTab` to create a new tab for behaviors, specifying its title, icon, route, and a `TreeLayout` component for displaying aggregated data. It also uses `allure.api.addWidget` to add a status view widget for behaviors to the overview dashboard. ```JavaScript allure.api.addTab('behaviors', { title: 'tab.behaviors.name', icon: 'fa fa-list', route: 'behaviors(/:testcaseId)', onEnter: (function () { var routeParams = Array.prototype.slice.call(arguments); return new allure.components.TreeLayout({ routeParams: routeParams, tabName: 'tab.behaviors.name', baseUrl: 'behaviors', url: 'data/behaviors.json' }); }) }); allure.api.addWidget('behaviors', allure.components.WidgetStatusView.extend({ title: 'widget.behaviors.name', baseUrl: 'behaviors', showLinks: false, showAllText: 'widget.behaviors.showAll' })); ``` -------------------------------- ### Configuring Allure Properties in pom.xml Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/maven.md Configures Allure report properties directly within the `allure-maven` plugin's `` section in `pom.xml`. This example demonstrates how to set a pattern for the issues tracker, allowing for inline customization of report behavior. ```xml io.qameta.allure allure-maven http://example.com/%s ``` -------------------------------- ### Configuring Allure Reporter in Protractor's onPrepare Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/jasmine.md This configuration shows how to integrate the Allure reporter within a Protractor test suite. The setup is placed inside the 'onPrepare' function of the Protractor configuration file ('conf.js'), ensuring the reporter is initialized before tests begin and results are directed to 'allure-results'. ```javascript // conf.js exports.config = { framework: 'jasmine2', onPrepare: function() { var AllureReporter = require('jasmine-allure-reporter'); jasmine.getEnv().addReporter(new AllureReporter({ resultsDir: 'allure-results' })); } } ``` -------------------------------- ### Example Allure Widget Data JSON (widgets.json) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This JSON snippet illustrates a portion of the 'widgets.json' file, specifically the entry for the "mywidget" defined by the 'MyPlugin' class. It contains filtered data (e.g., only failed test parameters) extracted by the 'getData' method, which will be displayed on the Overview tab as a widget. The '...' indicates it's part of a larger JSON structure. ```json ... "mywidget" : [ { "sounds" : [ "Oink!" ], "name" : "hungryCat" }, { "sounds" : [ "Moo!" ], "name" : "bigDog" } ], ... ``` -------------------------------- ### Mapping Tests to Features and Stories with Allure in PHP Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/php/phpunit.md This example illustrates how to classify PHPUnit tests by "stories" and "features" using the @Stories and @Features annotations provided by Allure. These annotations can be applied at both the class and method level, allowing for granular organization and filtering of tests in the generated Allure report. ```php namespace Example\Tests; use PHPUnit_Framework_TestCase; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; /** * @Stories({"story1", "story2"}) * @Features({"feature1", "feature2", "feature3"}) */ class SomeTest extends PHPUnit_Framework_TestCase { /** * @Features({"feature2"}) * @Stories({"story1"}) */ public function testCase() { //Some implementation here... } } ``` -------------------------------- ### Dividing Test Methods into Steps with Allure in PHP Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/php/phpunit.md This example shows how to divide complex test method logic into isolated "steps" using the StepSupport trait and the executeStep() method in Allure for PHPUnit. Each step can have an independent run status, providing clearer insight into failures within a test method and improving debugging. ```php namespace Example\Tests; use PHPUnit_Framework_TestCase; use Yandex\Allure\Adapter\Support\StepSupport; class SomeTest extends PHPUnit_Framework_TestCase { use StepSupport; public function testCase() { //Some implementation here... $this->executeStep("This is step one", function () { $this->stepOne(); }); $this->executeStep("This is step two", function () { $this-stepTwo(); }); $this->executeStep("This is step three", function () { $this->stepThree('someArgument'); }); //Some implementation here... } private function stepOne() { //Some implementation here... } private function stepTwo() { //Some implementation here... } private function stepThree($argument) { //Some implementation here... } } ``` -------------------------------- ### Displaying Allure CLI Help Information Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/commandline.md This command displays the available command-line options and arguments for the Allure CLI tool. It is useful for discovering various functionalities and their usage, providing a quick reference for all supported commands. ```shell script $ allure help ``` -------------------------------- ### Applying BDD Markers to Pytest Tests with Allure (Python) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This Python code illustrates the use of Allure's BDD-style decorators ('@allure.story', '@allure.feature') to categorize tests. It shows how to mark tests with specific stories and features, including an example of an epic (story starting with 'epic_') and how features and stories can be combined. ```python import allure def test_without_any_annotations_that_wont_be_executed(): pass @allure.story('epic_1') def test_with_epic_1(): pass @allure.story('story_1') def test_with_story_1(): pass @allure.story('story_2') def test_with_story_2(): pass @allure.feature('feature_2') @allure.story('story_2') def test_with_story_2_and_feature_2(): pass ``` -------------------------------- ### Defining a User Entity Class in Java Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit5.md This snippet defines a simple `User` class in Java with `name` and `password` fields. This class serves as an example entity whose fields can be accessed directly by name within Allure `@Step` annotations for smart field analysis, eliminating the need for explicit indexing or `toString()` overrides. ```java public class User { private String name; private String password; ... } ``` -------------------------------- ### Generating and Serving Allure Report (Gradle) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This shell command utilizes the `allureServe` task provided by the `allure-gradle` plugin to generate an HTML report from the collected results in `build/allure-results` and automatically opens it in a web browser. ```Shell $ ./gradlew allureServe build/allure-results ``` -------------------------------- ### Generating and Serving Allure Report (Maven) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This shell command uses the Allure CLI to generate an HTML report from the collected results located in `target/allure-results` and automatically opens the generated report in a web browser for immediate viewing. ```Shell $ allure serve target/allure-results ``` -------------------------------- ### Configuring Allure Environment with XML File Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/features.md This XML snippet illustrates the environment.xml file structure for populating the Allure report's Environment widget. It uses elements, each containing a and , to define environment details. This file provides an alternative, structured way to convey environment information compared to the properties file. ```XML Browser Chrome Browser.Version 63.0 Stand Production ``` -------------------------------- ### Running Gradle Build Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/kotlin/kotest.md This command executes the standard Gradle build process, including cleaning the project and running checks. It's a prerequisite for generating Allure results, which will be placed in the `build/allure-results` folder. ```shell ./gradlew clean check ``` -------------------------------- ### Installing Allure Cucumber Gem in Gemfile Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Adds the `allure-cucumber` gem to your application's Gemfile, making it a dependency for your project. ```Ruby gem 'allure-cucumber' ``` -------------------------------- ### Disabling Allure Cucumber Clean Directory Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/cucumber.md Disables the automatic deletion of previous Allure XML result files at the start of a new test run, preserving historical data. ```Ruby AllureCucumber.configure do |c| c.clean_dir = false end ``` -------------------------------- ### Generating and Serving Allure Report with Gradle Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/kotlin/kotest.md This command uses the Allure Gradle plugin to generate an HTML report from the collected Allure results and automatically opens it in a web browser. It specifies the `build/allure-results` directory as the source for the report data. ```shell ./gradlew allureServe build/allure-results ``` -------------------------------- ### Running Maven Build with Allure TestNG Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This shell command executes a Maven build, cleaning the project and running tests. Upon successful execution, Allure results will be generated in the `target/allure-results` folder, ready for report generation. ```Shell $ mvn clean test ``` -------------------------------- ### Running Gradle Build with Allure TestNG Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This shell command executes a Gradle build, cleaning the project and running tests. After execution, Allure results will be stored in the `build/allure-results` folder, ready for report generation. ```Shell $ ./gradlew clean test ``` -------------------------------- ### Generating Allure Report from Command Line Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/php/codeception.md This bash command demonstrates how to generate an Allure report using the `allure-cli` tool. It specifies the report version, the output path for the generated report (`tests/_output/allure-report`), and the input directory containing Allure results (`tests/_output/allure-results`). ```Bash allure generate --report-version 1.4.5 --report-path tests/_output/allure-report -- tests/_output/allure-results ``` -------------------------------- ### Running Maven Build Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/kotlin/kotest.md This command executes the standard Maven build lifecycle, including cleaning the project and running tests. This step is necessary to generate the Allure test results before report generation. ```shell mvn clean test ``` -------------------------------- ### Defining Allure Steps with Smart Field Extraction Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This Java code demonstrates how to define a test step using the `@Step` annotation from `io.qameta.allure`. It highlights Allure 2's reflection-based approach for smart field extraction, enabling direct access to object properties like `{user.name}` and `{user.password}` within the step name string. ```Java public class User { private String name; private String password; ... } import io.qameta.allure.Step; ... @Step("Type {user.name} / {user.password}.") public void loginWith(User user) { ... } ``` -------------------------------- ### Styling Custom Logo in Allure Report (CSS) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/existing.md This CSS snippet overrides the default Allure logo by setting the background of the `.side-nav__brand` element. It uses `custom-logo.svg` as the background image, ensuring it doesn't repeat and is positioned at the left center, with a 10px left margin. ```CSS .side-nav__brand { background: url('custom-logo.svg') no-repeat left center; margin-left: 10px; } ``` -------------------------------- ### Running Gradle Tests with Allure Integration Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit5.md This command executes the Gradle build, including tests, after the build.gradle has been configured for Allure. It cleans the project and runs the tests, which will generate Allure results. ```Shell $ ./gradlew clean test ``` -------------------------------- ### Creating Allure Attachments with @Attachment Annotation in Java Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/cucumber.md This Java code demonstrates how to use the io.qameta.allure.Attachment annotation to add data to Allure reports. It shows examples of attaching a String by returning its value and attaching a byte[] (e.g., a screenshot) while specifying its MIME type. ```Java import io.qameta.allure.Attachment; ... @Attachment public String performedActions(ActionSequence actionSequence) { return actionSequence.toString(); } @Attachment(value = "Page screenshot", type = "image/png") public byte[] saveScreenshot(byte[] screenShot) { return screenShot; } ``` -------------------------------- ### Generating and Serving Allure HTML Report with Gradle Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit5.md This command generates an HTML report from the Allure results and automatically opens it in a web browser. It requires the allure-gradle plugin to be configured in the project. ```Shell $ ./gradlew allureServe ``` -------------------------------- ### Configuring Allure Gradle Plugin Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/kotlin/kotest.md This snippet demonstrates how to configure the Allure Gradle plugin in a `build.gradle` file. It includes adding the `io.qameta.allure` plugin, specifying Allure's version, disabling autoconfiguration, and adding the `kotest-extensions-allure` dependency for test implementation. ```groovy plugins { id("io.qameta.allure") version "2.8.1" } allure { version = '2.13.1' autoconfigure = false } dependencies { testImplementation("io.kotest:kotest-extensions-allure:LATEST_VERSION") } ``` -------------------------------- ### Including AllureRSpec Adaptor in RSpec Configuration Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/ruby/rspec.md This configuration block shows how to include the AllureRSpec::Adaptor module within your RSpec setup (typically in spec_helper.rb). This step is essential to enable Allure's functionalities within your RSpec tests. ```Ruby RSpec.configure do |c| c.include AllureRSpec::Adaptor end ``` -------------------------------- ### Creating and Registering a Custom Widget for Allure Overview (JavaScript) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This snippet defines `MyWidget` as a Backbone.Marionette.View to display data from `widgets.json` on the Allure Overview page. It uses a `widgetTemplate` function for rendering and `serializeData` to prepare the model's items for the template. Finally, it registers the widget using `allure.api.addWidget`. ```JavaScript class MyWidget extends Backbone.Marionette.View { template(data) { return widgetTemplate(data) } serializeData() { return { items: this.model.get('items'), } } } allure.api.addWidget('mywidget', MyWidget); ``` -------------------------------- ### Configuring Allure Plugin with YAML Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This YAML configuration file defines the metadata and components of an Allure plugin. It specifies the plugin's ID, name, description, fully qualified names of Java extension classes that implement `Extension` interface for data processing, and front-end JavaScript and CSS files for report representation. ```YAML id: my-plugin name: Plugin name goes here description: More detailed explanation of what does this plugin do. extensions: - my.company.allure.CustomPlugin // - Fully qualified names of classes that implement `Extension` interface and comprise data processing functionality. - my.company.allure.CustomWidget jsFiles: - index.js cssFiles: - styles.css ``` -------------------------------- ### Configuring Allure Environment with Properties File Source: https://github.com/allure-framework/allure-docs/blob/main/content/gettingstarted/features.md This snippet shows the environment.properties file format used to add custom information to the Allure report's Environment widget. Each line represents a key-value pair, where the key describes an environment aspect (e.g., Browser, Stand) and the value provides its specific detail. This file must be placed in the allure-results directory before report generation. ```Properties Browser=Chrome Browser.Version=63.0 Stand=Production ``` -------------------------------- ### Running Maven Tests with Allure Integration Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit5.md This command executes the Maven build, including tests, after the pom.xml has been configured for Allure. It cleans the project and runs the tests, which will generate Allure results. ```Shell $ mvn clean test ``` -------------------------------- ### Marking Expected Failures with Pytest xfail Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This Python code demonstrates the use of @pytest.mark.xfail to mark tests that are expected to fail. It includes examples for an expected failure (where the test fails as anticipated) and an unexpected pass (where an xfail-marked test passes, resulting in a special 'xpass' status in Allure). ```Python @pytest.mark.xfail(condition=lambda: True, reason='this test is expecting failure') def test_xfail_expected_failure(): """this test is an xfail that will be marked as expected failure""" assert False @pytest.mark.xfail(condition=lambda: True, reason='this test is expecting failure') def test_xfail_unexpected_pass(): """this test is an xfail that will be marked as unexpected success""" assert True ``` -------------------------------- ### Configuring Allure Maven Plugin Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/kotlin/kotest.md This XML snippet for `pom.xml` configures Allure for Maven projects. It adds the `kotest-extensions-allure` dependency, sets up the `maven-surefire-plugin` to run tests, and integrates the `allure-maven` plugin for report generation, specifying the Allure report version. ```xml io.qameta.allure kotest-extensions-allure LATEST_VERSION test maven-surefire-plugin 2.21 false io.qameta.allure allure-maven LATEST_VERSION 2.13.1 ``` -------------------------------- ### Publishing Signed Artifacts with sbt Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/scala/scala-test.md This command is used to publish signed artifacts to a configured repository, typically Sonatype. It requires the Sonatype credentials to be set up in `sonatype.sbt` and a GPG key for signing. ```Shell sbt publish-signed ``` -------------------------------- ### Assigning Allure Features and Stories to Test Classes in Nose Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/nose.md This Python example demonstrates applying Allure features and stories to an entire test class using `@nose.allure.feature` and `@nose.allure.story` decorators. All test methods within the decorated class will inherit these categorizations, simplifying organization for related tests. ```Python import nose class TestBar(object): @nose.allure.feature('Feature2') @nose.allure.story('Story1') def test_bar(self): pass ``` -------------------------------- ### Marking Test Severity with Allure Decorator (Custom Level) in Nose Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/nose.md This Python example shows how to apply a custom severity string (e.g., 'hard') to a test function using the `@nose.allure.severity` decorator. This flexibility allows for defining project-specific severity categories beyond the standard Allure levels. ```Python import nose @nose.allure.severity("hard") def test_bar(self): pass ``` -------------------------------- ### Adding Screenshots as Allure Attachments in Protractor Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/jasmine.md This JavaScript snippet demonstrates how to automatically capture a screenshot after each test in Protractor and attach it to the Allure report. It uses 'browser.takeScreenshot()' to get a PNG, then 'allure.createAttachment()' to add it to the report with a specified name and MIME type. The 'done' callback is crucial for asynchronous operations. ```javascript onPrepare: function () { var AllureReporter = require('jasmine-allure-reporter'); jasmine.getEnv().addReporter(new AllureReporter()); jasmine.getEnv().afterEach(function(done){ browser.takeScreenshot().then(function (png) { allure.createAttachment('Screenshot', function () { return new Buffer(png, 'base64') }, 'image/png')(); done(); }) }); } ``` -------------------------------- ### Running Gradle Build with Allure Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit4.md This command executes a clean build and runs tests for a Gradle project configured with the allure-gradle plugin. It processes tests and generates Allure results in the build/allure-results folder. ```shell ./gradlew clean test ``` -------------------------------- ### Defining Test Steps with Allure Decorator (Auto-named) in Nose Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/nose.md This Python example shows how to use `@nose.allure.step` as a decorator on a helper function. When used without arguments, the step name is automatically derived from the decorated method's name, providing a concise way to mark parts of a test as steps. ```Python import nose @nose.allure.step def make_test_data_foo(): # do stuff def test_foo(): assert make_test_data_foo() is not None ``` -------------------------------- ### Running Mocha Tests with Allure Reporter Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/mocha.md This command executes Mocha tests and specifies `mocha-allure-reporter` as the reporter. After execution, raw test results will be generated in the `allure-results` directory, which can then be used to generate a full Allure report. ```Shell mocha --reporter mocha-allure-reporter ``` -------------------------------- ### Full Allure Gradle Plugin Configuration Options Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/gradle.md This comprehensive configuration block details all available parameters for the Allure Gradle plugin. It allows fine-grained control over aspects like autoconfiguration, AspectJ Weaver inclusion, result and report directories, dependency configuration, Allure Java version, and custom download links for the Allure commandline tool, alongside specific versioning for JUnit4, TestNG, Cucumber JVM, and Spock adapters. ```Groovy allure { version = '2.2.1' autoconfigure = false String allureJavaVersion = '2.0-BETA9' aspectjweaver = true boolean clean = true resultsDir = file('/path/to/project/module/build/allure-results') reportDir = file('build/reports/allure-report') String configuration = 'testCompile' useJunit4 { version = '2.0-BETA12' } useTestNG { version = '2.0-BETA12' spi-off = false } useCucumberJVM { version = '2.0-BETA12' } useSpock { version = '2.0-BETA12' } downloadLink = 'https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.2.1/allure-2.2.1.zip' // Allure >= 2.8.0 is no longer available on Bintray // downloadLink = 'https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.8.1/allure-commandline-2.8.1.zip' } ``` -------------------------------- ### Adding Attachments to Allure Reports in Python Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This snippet demonstrates how to add various types of attachments to Allure reports using `allure.attach` for raw content and `allure.attach.file` for file-based content. It includes examples of attaching text in a fixture's finalizer and attaching image and HTML content directly within a test. ```python import allure import pytest @pytest.fixture def attach_file_in_module_scope_fixture_with_finalizer(request): allure.attach('A text attacment in module scope fixture', 'blah blah blah', allure.attachment_type.TEXT) def finalizer_module_scope_fixture(): allure.attach('A text attacment in module scope finalizer', 'blah blah blah blah', allure.attachment_type.TEXT) request.addfinalizer(finalizer_module_scope_fixture) def test_with_attacments_in_fixture_and_finalizer(attach_file_in_module_scope_finalizer): pass def test_multiple_attachments(): allure.attach.file('./data/totally_open_source_kitten.png', attachment_type=allure.attachment_type.PNG) allure.attach(' a page ', 'Attach with HTML type', allure.attachment_type.HTML) ``` -------------------------------- ### Prioritizing Allure Tests by Severity in Java Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/junit5.md This Java example demonstrates how to assign a severity level to a test method using the `@Severity` annotation from `io.qameta.allure`. The `SeverityLevel` enum provides predefined levels such as `CRITICAL`. This annotation helps in prioritizing and filtering test results based on their importance in the Allure report. ```java package org.example.tests; import org.junit.Test; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; public class MyTest { @Test @Severity(SeverityLevel.CRITICAL) public void testSomething() throws Exception { // ... } } ``` -------------------------------- ### Adding Detailed Description to Test Methods Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This Java code snippet illustrates the use of the `@Description` annotation from `io.qameta.allure` to add a detailed, multi-line description to a test method. This description provides additional context and will be displayed within the Allure report, enhancing test readability. ```Java package my.company.tests; import org.junit.Test; import io.qameta.allure.Description; @Test public class MyTests { @Test @Description("Some detailed test description") public void testSomething() throws Exception { ... } } ``` -------------------------------- ### Serving Allure HTML Report with Maven Jetty Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/jasmine.md This command serves the generated Allure HTML reports locally using the Maven Jetty plugin. It runs a local web server, making the reports accessible via a specified port (e.g., 1234) on localhost. This is useful for quickly viewing reports without deploying them. ```shell mvn jetty:run -Djetty.port=1234 ``` -------------------------------- ### Demonstrating Basic Pytest Statuses in Allure Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This Python code defines four Pytest functions demonstrating different test outcomes: success, failure (due to assertion), skip (explicitly skipped), and broken (due to an unhandled exception). These examples illustrate how Allure reports categorize and display each of these standard Pytest statuses. ```Python import pytest def test_success(): """this test succeeds""" assert True def test_failure(): """this test fails""" assert False def test_skip(): """this test is skipped""" pytest.skip('for a reason!') def test_broken(): raise Exception('oops') ``` -------------------------------- ### Configuring Allure TestNG with Gradle Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md This Groovy snippet configures a `build.gradle` file to integrate Allure TestNG using the `allure-gradle` plugin. It adds the plugin to the buildscript classpath and sets various Allure properties such as version, autoconfigure, and AspectJ weaver enablement. ```Groovy buildscript { repositories { jcenter() } dependencies { classpath "io.qameta.allure:allure-gradle:2.3" } } plugins { id 'io.qameta.allure' } allure { version = '2.2.1' autoconfigure = true aspectjweaver = true allureJavaVersion = LATEST_VERSION } ``` -------------------------------- ### Default Allure Plugin Configuration (YAML) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This YAML configuration file (`allure.yml`) lists the default plugins enabled in the Allure commandline distribution. It specifies the folders of the plugins to be used during report generation, such as `behaviors-plugin`, `junit-plugin`, and `screen-diff-plugin`. ```YAML plugins: - behaviors-plugin - junit-plugin - screen-diff-plugin ``` -------------------------------- ### Gradle Build Script for Allure Plugin (Groovy) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This Gradle build script configures a plugin project. It applies the `java-library-distribution` plugin, sets the `plugin.jar` archive name, and declares a `compileOnly` dependency on `allure-plugin-api`, ensuring the plugin can be compiled against the Allure API without bundling it. ```Groovy repositories { jcenter() } apply plugin: 'java-library-distribution' jar { archiveName = 'plugin.jar' } dependencies { compileOnly('io.qameta.allure:allure-plugin-api:2.0-BETA8') } ``` -------------------------------- ### Assigning Severity Levels to Pytest Tests with Allure (Python) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/python/pytest.md This Python code demonstrates how to apply severity levels to tests using the '@allure.severity' decorator with 'allure.severity_level' enum values. It shows examples of marking individual functions and an entire test class, including how a method within a class can override the class's severity level. ```python import allure def test_with_no_severity_label(): pass @allure.severity(allure.severity_level.TRIVIAL) def test_with_trivial_severity(): pass @allure.severity(allure.severity_level.NORMAL) def test_with_normal_severity(): pass @allure.severity(allure.severity_level.NORMAL) class TestClassWithNormalSeverity(object): def test_inside_the_normal_severity_test_class(self): pass @allure.severity(allure.severity_level.CRITICAL) def test_inside_the_normal_severity_test_class_with_overriding_critical_severity(self): pass ``` -------------------------------- ### Running Cucumber.js Basic Configuration Tests Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/js/cucumber.md This shell command executes Cucumber.js tests related to basic configuration, located in the `miscellaneous/configuration` directory. ```shell ./node_modules/.bin/cucumber.js miscellaneous/configuration ``` -------------------------------- ### Defining Backbone Model and Layout for Allure Tab (JavaScript) Source: https://github.com/allure-framework/allure-docs/blob/main/content/plugins/overview.md This snippet defines `MyTabModel` as a Backbone Collection to fetch data from `data/myplugindata.json` and `MyLayout` extending `allure.components.AppLayout`. `MyLayout` initializes `MyTabModel`, loads data using `fetch()`, and provides a content view using `MyView`. ```JavaScript var MyTabModel = Backbone.Collection.extend({ url: 'data/myplugindata.json' }) class MyLayout extends allure.components.AppLayout { initialize() { this.model = new MyTabModel(); } loadData() { return this.model.fetch(); } getContentView() { return new MyView({items: this.model.models}); } } ``` -------------------------------- ### Configuring AllureReporter for Specs2 Tests in SBT Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/scala/specs.md This configuration snippet shows how to attach the AllureReporter to Specs2 tests within an SBT build. It uses `testOptions in Test` to add a `Tests.Argument` that specifies `AllureNotifier` as the test framework notifier, directing test results to Allure. This setup is crucial for generating Allure reports from Specs2 test executions. ```SBT testOptions in Test ++= Seq( Tests.Argument(TestFrameworks.Specs2, "notifier", "ru.yandex.qatools.allure.specs2.AllureNotifier") ) ``` -------------------------------- ### Adding Allure Attachments with Allure Helper Methods (Java) Source: https://github.com/allure-framework/allure-docs/blob/main/content/frameworks/java/testng.md Illustrates the use of `Allure.addAttachment` helper methods for programmatically adding attachments to Allure reports. This allows adding content directly from strings or input streams, providing more flexible attachment handling. ```Java import io.qameta.allure.Allure; ... Allure.addAttachment("My attachment", "My attachment content"); Path content = Paths.get("path-to-my-attachment-contnet"); try (InputStream is = Files.newInputStream(content)) { Allure.addAttachment("My attachment", is); } ``` -------------------------------- ### Generating Allure Report from Results Source: https://github.com/allure-framework/allure-docs/blob/main/content/reporting/commandline.md This command generates an Allure report from the specified directory containing Allure results. The report is created in the 'allure-report' folder by default, visualizing test execution data and providing insights. ```shell script $ allure generate ```