Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Parameters

Mihails Volkovs edited this page May 13, 2015 · 13 revisions

Environment and test case properties

Parameter is any value describing your test environment or current test case. A parameter can store something that doesn't change during all tests (such as the test stand address), or something that changes from test case to test case (such as the test page URL).

Adding parameters in Java looks like this (see https://github.com/allure-framework/allure-core/pull/286):

public class TestClass {
    ...
    @Parameter("My Param")
    private String myParameter;
    ...
}

Any value assigned to such a field will be shown in the report.

Note: Constant fields (static final) with a String or primitive value type (int, float, long, etc.) don't work with @Parameter annotation because of Java implementation particularities.

Parameterized tests

Some test frameworks support parametrized tests, i.e. the same test is executed multiple times with different parameters. Test parameter names and values can be made visible in Allure report.

TestNG

Test method parameters can be marked with @Parameter annotation:

public void parametrizedTest(@Parameter int age, 
                             @Parameter("Name") String parameter2, 
                             @Parameter("Surname") String parameters3) {
    ...
}

If parameter name is not defined in @Parameter annotation following default names are used:

  • in Java 7 default parameter naming is used (arg0, arg1, ... )
  • Java 8 allows to keep test method parameter names in class files (needs javac -parameters compilation)