Skip to content

Conversation

@jean-andre-gauthier
Copy link
Member

@jean-andre-gauthier jean-andre-gauthier commented Apr 4, 2024

@jean-andre-gauthier jean-andre-gauthier force-pushed the jgauthier/269/parentheses branch from 46e1eb8 to df89987 Compare April 4, 2024 15:54
@jean-andre-gauthier jean-andre-gauthier changed the title Initial setup for kotlin test Add support for tests with parentheses at the end of the name Apr 5, 2024
@jean-andre-gauthier jean-andre-gauthier force-pushed the jgauthier/269/parentheses branch from 4647bb7 to 267db85 Compare April 8, 2024 07:24
@jean-andre-gauthier jean-andre-gauthier marked this pull request as ready for review April 8, 2024 07:35
private void addPotentiallyParameterizedSuffixed(TestFilterBuilder filters, String className, String name) {
// It's a common pattern to add all the parameters on the end of a literal method name with []
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\)|\\[[^]]*?])*$", "");
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\))?(?:\\[[^]]*?](?:\\([^)]*?\\))?)?$", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

Copy link
Member

@pshevche pshevche Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, can we add a comment explaining what should match and what not? Or maybe a unit test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've realised I made the regex more complicated than necessary. I've updated it to match only (...), or (...)[...], added a comment, and an additional test case in ParenthesesFuncTest

private void addPotentiallyParameterizedSuffixed(TestFilterBuilder filters, String className, String name) {
// It's a common pattern to add all the parameters on the end of a literal method name with []
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\)|\\[[^]]*?])*$", "");
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\))?(?:\\[[^]]*?](?:\\([^)]*?\\))?)?$", "");
Copy link
Member

@pshevche pshevche Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, can we add a comment explaining what should match and what not? Or maybe a unit test?

@jean-andre-gauthier jean-andre-gauthier added this to the 1.5.8 milestone Apr 10, 2024
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.

Test methods with parenthesis in their names are correctly retried

5 participants