-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
There was a problem hiding this 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')} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
build-data-capturing-gradle-samples/capture-test-pts-support/gradle-test-pts-support.gradle
Outdated
Show resolved
Hide resolved
…up "io.cucumber".
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
53d6321
to
d3f0ed7
Compare
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 asSUPPORTED
, otherwise we mark it asENGINES_NOT_ALL_SUPPORTED
if cucumber is detected.This is a followup on the slack thread