allure-framework / allure-framework/allure-java
Add precondition method and annotation for update precondition field in test case from test result
- Ngôn ngữ chính
- Java
- Star
- 376
- Fork
- 240
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 45
Mô tả
### What problem should this solve?
There is "Precondition" update policy in testops. And when the test result is selected, there is no way to specify what should be selected to fill in the field.
I talked to testops support and they said that there is no label that they could add to this field. And that you need to add the task to the appropriate framework.
### What would you like to happen?
It would be convenient for the Allure.precondition method and the @Precondition annotation to appear, which would preserve the group of steps as a separate entity. Then, during the processing of the test results, these steps would fall into the corresponding block in both lunch and test cases.
### Alternatives considered
_No response_
### Additional context
An example of how to use this at the test level. The tests are designed to show what is required. In 1 test, it's just using a method, in the second, there are 2 method calls in a row, and the third test is an example of how an annotated method is used.
For the second test, 2 calls were used because sometimes it is necessary to prepare several different entities for the test, but it is impossible to return 2 values from anonymity without creating additional entities of the Map/Array type or class fields.
```
package ...
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class Example {
private User user;
@BeforeClass(description = "Подготовка данных для тестов")
public void prepareTestData() {
dbSteps().cleanUsers();
user = prepareUser("main-region-user-name", "test", "region-main");
}
@BeforeMethod(description = "Подготовка между тестами")
public void prepareTests() {
dbSteps().cleanUserJoins(user);
}
@Test(description = "Объединение пользователя в главный регион")
public void joinUserToMainRegion() {
var userForJoin = Allure.precondition(() -> prepareUser("region-1-user-name", "test", "region-1"));
apiSteps().joinUsers(user, userForJoin).check(
response -> response.shouldOk()
.userIdShould(equalTo(user.id()))
.joinedUserIdsShould(hasSize(1))
.joinedUserIdsShould(everyItem(equalTo(userForJoin.id())))
);
}
@Test(description = "Объединение нескольких пользователей из разных регионов в главный регион")
public void joinUsersFromDifferentRegionsToMainRegion() {
var firstUserForJoin = Allure.precondition(() -> prepareUser("region-1-user-name", "test", "region-1"));
var secondUserForJoin = Allure.precondition(() -> prepareUser("region-2-user-name", "test", "region-2"));
apiSteps().joinUsers(user, firstUserForJoin, secondUserForJoin).check(
response -> response.shouldOk()
.userIdShould(equalTo(user.id()))
.joinedUserIdsShould(hasSize(2))
.joinedUserIdsShould(equalTo(List.of(firstUserForJoin.id(), secondUserForJoin.id())))
);
}
@Precondition
public User userInBlockedRegion(String name, String lastName, String regionId) {
dbStesp().setRegionBlocked(regionId);
return prepareUser(name, lastName, regionId);
}
@Test(description = "Объединение пользователя в главный регион из заблокированного")
public void joinUserToMainRegionFromBlocked() {
var regionId = "region-35";
var userForJoin = userInBlockedRegion("region-blocked-user-name", "test", regionId);
apiSteps().joinUsers(user, userForJoin).check(
response -> response.shouldError(new ApiError(500, "Region '%s' blocked".formatted(regionId)))
);
}
}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách lần theo các điểm vào tích hợp Java xử lý kết quả kiểm thử và các mẫu API và annotation hiện có của Allure; issue không nêu tệp hoặc kiểm thử nào. So sánh phương thức và annotation được yêu cầu với các ví dụ TestNG được cung cấp, bao gồm nhiều lệnh gọi precondition và các giá trị được trả về. Hoàn thành có nghĩa là các bước precondition được giữ riêng biệt và xuất hiện trong các khối precondition TestOps tương ứng cho các test case và launch.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- testing
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100