Custom fields
Custom fields are custom attributes you can add to your test cases to provide more information about them. Each custom field is a name-value pair, that is, the name of a field is fixed, but the value can vary for test cases.
For example, you can add a "Suite" field to a test case and specify the name of the test suite this test case belongs to.
By default, Allure Testops provides four custom fields you can use: Epic, Feature, Story, and Suite. To create your own custom fields, you need to sign in to Allure Testops as administrator.
Custom fields can be used to filter the test cases (using filters, custom views, or AQL queries) and to create test plans.
You can add custom fields to test cases manually using the web interface or automatically from the test results you upload to Allure Testops. If you want to add custom fields to automated test cases manually, you need to change your project's upload policy.
Managing available custom fields
- Log in to Allure Testops using an administrator account.
- Click on your avatar and go to Administration → Custom Fields.
- To create a new custom field, click the Create button and enter a name for the new field.
To rename a previously created field, click the pencil icon on the right side of the custom field. To delete a custom field, click the trash bin icon.
Adding custom fields to test cases manually
- Go to the Test cases section of your project.
- Select a test case.
- On the right side of the page, next to Fields, click the pencil icon.
- Click the Add button.
- Under Custom Field, select the custom field you want to add.
- Under Value, enter a value or select a previously used one.
- Click Submit.
To delete a previously added custom field, click the cross icon.
Setting custom fields automatically from test results
Custom fields can be added to test cases automatically when you upload test results to Allure Testops. For this to work, you need to specify them in your integration code and create mappings in your project settings.
Specifying custom fields in code
The exact implementation will depend on the testing framework you use, but as an example, here is what it might look like if you are using JUnit 5:
@Test
@Feature("Regions")
@DisplayName("Creating new issue by authorized user")
public void shouldCreateIssue() {
steps.openIssuesPage(OWNER, REPO);
steps.createIssueWithTitle(ISSUE_TITLE);
steps.shouldSeeIssueWithTitle(ISSUE_TITLE);
}
Notice the line starting with @Feature. This line adds a Feature custom field with the value Regions.
The code above will generate a test result file with the field "labels". This field contains the attributes that will be applied to the test case when the file is uploaded to Allure Testops.
...
"labels": [
{
"name": "feature",
"value": "Regions"
},
...
You can read more about using labels in the corresponding article.
Creating mappings
- Go to the project page.
- In the menu on the left, click Settings → Custom Fields.
- Click the Create button.
- As the Key, specify the value you use in your code. For the example above, it is feature.
- As the Custom field, select the custom field you want to associate with the entered key. For the example above, it is Feature.
- Click Submit.
Changing upload policy
If you want to add custom fields to automated test cases using the web interface instead of specifying them in test results, you can change your upload policy to ignore custom fields from test results.
- Go to the project page.
- In the menu on the left, click Settings → Upload.
- Click the Create button.
- Under Field, select custom_field.
- Under Policy, select from_test_case.
- Click Submit.