Skip to content
Merged
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 @@ -29,7 +29,7 @@ private TestData() {
}

public static String randomString() {
return RandomStringUtils.randomAlphabetic(10);
return RandomStringUtils.insecure().nextAlphabetic(10);
}

public static int randomPort() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ protected static List<TreeLayer> groupByCategories(final TestResult testResult)
return Arrays.asList(categoriesLayer, messageLayer);
}

@SuppressWarnings("CyclomaticComplexity")
public static boolean matches(final TestResult result, final Category category) {
final boolean matchesStatus = category.getMatchedStatuses().isEmpty()
|| nonNull(result.getStatus())
Expand All @@ -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 = 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public static JiraService mockJiraService() {

public static TestResult createTestResult(final Status status) {
return new TestResult()
.setUid(RandomStringUtils.random(10))
.setName(RandomStringUtils.random(10))
.setHistoryId(RandomStringUtils.random(9))
.setUid(RandomStringUtils.insecure().nextAlphanumeric(10))
.setName(RandomStringUtils.insecure().nextAlphanumeric(10))
.setHistoryId(RandomStringUtils.insecure().nextAlphanumeric(9))
.setStatus(status);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void shouldExportTestRunToXray() {
when(launchResults.getAllResults()).thenReturn(results);

final ExecutorInfo executorInfo = new ExecutorInfo()
.setBuildName(RandomStringUtils.random(10))
.setReportUrl(RandomStringUtils.random(10));
.setBuildName(RandomStringUtils.insecure().next(10))
.setReportUrl(RandomStringUtils.insecure().next(10));
when(launchResults.getExtra("executor")).thenReturn(Optional.of(executorInfo));

final JiraService service = mock(JiraService.class);
Expand Down Expand Up @@ -124,8 +124,8 @@ void shouldExportTestRunToXrayWithAllTypesOfStatues() {
when(launchResults.getAllResults()).thenReturn(results);

final ExecutorInfo executorInfo = new ExecutorInfo()
.setBuildName(RandomStringUtils.random(10))
.setReportUrl(RandomStringUtils.random(10));
.setBuildName(RandomStringUtils.insecure().next(10))
.setReportUrl(RandomStringUtils.insecure().next(10));
when(launchResults.getExtra("executor")).thenReturn(Optional.of(executorInfo));

final JiraService service = mock(JiraService.class);
Expand Down Expand Up @@ -173,8 +173,8 @@ void shouldUpdateSimilarTestRunsInDifferentExecutions() {
when(launchResults.getAllResults()).thenReturn(results);

final ExecutorInfo executorInfo = new ExecutorInfo()
.setBuildName(RandomStringUtils.random(10))
.setReportUrl(RandomStringUtils.random(10));
.setBuildName(RandomStringUtils.insecure().next(10))
.setReportUrl(RandomStringUtils.insecure().next(10));
when(launchResults.getExtra("executor")).thenReturn(Optional.of(executorInfo));

final JiraService service = mock(JiraService.class);
Expand Down Expand Up @@ -212,8 +212,8 @@ void shouldUpdateSimilarTestRunsInDifferentExecutions() {

static TestResult createTestResult(final Status status) {
return new TestResult()
.setUid(RandomStringUtils.random(10))
.setName(RandomStringUtils.random(10))
.setUid(RandomStringUtils.insecure().next(10))
.setName(RandomStringUtils.insecure().next(10))
.setStatus(status);
}

Expand Down