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 null exception in anyTestMethodNamesMatch predicate #146

Merged
merged 1 commit into from
Feb 21, 2023

Conversation

andre15silva
Copy link
Contributor

Sometimes, the Description object given to the anyTestMethodNamesMatch predicate does not represent a method.

In those cases, the ListenerUtils.getMethodName function returns null, leading to a NullPointerException when we try to match said null object in a regex Matcher in

private final Predicate<Description> anyTestMethodNamesMatch = description ->
this.testMethodNames.stream()
.anyMatch(testMethodName ->
Pattern.compile("(" + ListenerUtils.getClassName.apply(description) + ")?" + testMethodName + "\\[(\\d+)\\]")
.matcher(ListenerUtils.getMethodName.apply(description))
.find()
) ||
this.testMethodNames.contains(ListenerUtils.getMethodName.apply(description)) ||
this.testMethodNames.contains(ListenerUtils.getClassName.apply(description) + "#" + ListenerUtils.getMethodName.apply(description));

This PR fixes that issue by introducing a null check in said predicate.

@andre15silva
Copy link
Contributor Author

Hi @danglotb :)

Would you be able to review this PR?
It is linked with ASSERT-KTH/flacoco#153 (comment)

Merci!

@danglotb
Copy link
Member

LGTM

@danglotb danglotb merged commit 9f2bd27 into STAMP-project:master Feb 21, 2023
@andre15silva
Copy link
Contributor Author

Thanks :)

@monperrus
Copy link
Member

monperrus commented Feb 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants