Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix falky test results categories matching #2796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -161,7 +162,8 @@ public static boolean matches(final TestResult result, final Category category)
final boolean matchesTrace = isNull(category.getTraceRegex())
|| nonNull(result.getStatusTrace())
&& matches(result.getStatusTrace(), category.getTraceRegex());
final boolean matchesFlaky = result.isFlaky() == category.isFlaky();
final boolean matchesFlaky = Objects.isNull(category.getFlaky())
|| result.isFlaky() == category.getFlaky();
return matchesStatus && matchesMessage && matchesTrace && matchesFlaky;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public class Category implements Serializable {
protected String messageRegex;
protected String traceRegex;
protected List<Status> matchedStatuses = new ArrayList<>();
protected boolean flaky;
protected Boolean flaky;

}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,38 @@ meta, createTestResult("asd\n", Status.FAILED, true)
.containsKey("data/" + JSON_FILE_NAME);
}

@Test
void flakyTestsShouldBeMatchedByDefault() {
final Configuration configuration = ConfigurationBuilder.bundled().build();

final Category category = new Category()
.setName(CATEGORY_NAME)
.setMatchedStatuses(singletonList(Status.FAILED));

final Map<String, Object> meta = new HashMap<>();
meta.put("categories", singletonList(category));

final List<LaunchResults> launchResultsList = createSingleLaunchResults(
meta, createTestResult("asd\n", Status.FAILED, true)
);

final CategoriesPlugin plugin = new CategoriesPlugin();

final InMemoryReportStorage storage = new InMemoryReportStorage();
plugin.aggregate(configuration, launchResultsList, storage);

final Set<TestResult> results = launchResultsList.get(0).getAllResults();
List<Category> categories = results.toArray(new TestResult[]{})[0]
.getExtraBlock("categories");

assertThat(categories).as("test categories")
.extracting(Category::getName)
.containsExactly(category.getName());

assertThat(storage.getReportDataFiles())
.containsKey("data/" + JSON_FILE_NAME);
}

@Issue("587")
@Issue("572")
@Test
Expand Down
Loading