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

Added detecting cucumber support to pts scripts #948

Merged
merged 4 commits into from
Dec 6, 2023

Conversation

ribafish
Copy link
Member

Added detecting cucumber support to pts scripts.

Since cucumber can also be used without cucumber-junit-platform-engine we can't rely solely on detecting the engine, so I've added checking if any cucumber dependencies were added to the classpath of the test task. If cucumber is found, we check whether the cucumber companion plugin is added. If it's missing we mark it as SUPPORTED, otherwise we mark it as ENGINES_NOT_ALL_SUPPORTED if cucumber is detected.

This is a followup on the slack thread

Copy link
Contributor

@runningcode runningcode left a comment

Choose a reason for hiding this comment

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

looks good, just had two comments

}

boolean cucumberUsed(Test t, Set<String> engines) {
return t.classpath.any { f -> f.name.contains('cucumber')} || engines.any { it.contains('cucumber')}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we can be more specific here and check the group id? I want to prevent another package that has the word cucumber in it from causing confusion here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@ribafish ribafish requested a review from runningcode December 1, 2023 08:52
boolean cucumberUsed(Test t, Set<String> engines) {
return t.classpath.any { f -> f.name.contains('cucumber')} || engines.any { it.contains('cucumber')}
boolean cucumberUsed(Test t) {
return t.project.configurations.stream().filter { it.canBeResolved }.any {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the testImplementation always a resolvable dependency? I'm wondering if there are cases where this check would just return false or true incorrectly if it isn't resolvable.

Copy link
Member Author

@ribafish ribafish Dec 4, 2023

Choose a reason for hiding this comment

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

Well, the code will check all configurations. As for if testImplementation is always resolvable...I'm not sure, but if it's not resolvable, then how it would work (the project setup itself) without it being resolved?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think testImplementation is resolvable in the same way that implementation is not resolvable. They just declare a group of dependencies. Can you please check?

This is a useful blog post that someone in our slack linked to that covers this topic.
https://dev.to/autonomousapps/configuration-roles-and-the-blogging-industrial-complex-21mn

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true, however, at the end, in order for a dependency to be used it will need to be resolved in one of the configurations. The implementation I made will check all resolvable implementations for cucumber. Or am I missing something?

Note: I decided not to use the task.classpath, as that's a file collection and getting the group id from jars is more complicated than this, as well as not as exact (for example for shaded dependencies).

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method iterating through the dependencies of testImplementation? y/n? You can debug this if needed with some printlines (or tagging).

Copy link
Member Author

Choose a reason for hiding this comment

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

No, for a simple cucumber test project it's checking

annotationProcessor
compileClasspath
cucumberRuntime
runtimeClasspath
testAnnotationProcessor
testCompileClasspath
testRuntimeClasspath

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I think we only need to check the test configurations. For example, if the compileClasspath contains cucumber then it isn't necessarily being used in a test (perhaps we're building a cucumber based plugin or framework).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok since there isn't a good way to detect only the test configuration and we assume that this script will be used with a solutions engineer present this is okay.

@ribafish ribafish force-pushed the gk/ptsSupportScript_cucumber branch from 53d6321 to d3f0ed7 Compare December 4, 2023 08:14
@ribafish ribafish merged commit b454c95 into main Dec 6, 2023
21 checks passed
@ribafish ribafish deleted the gk/ptsSupportScript_cucumber branch December 6, 2023 09:01
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.

4 participants