-
Notifications
You must be signed in to change notification settings - Fork 470
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
SpockConfig can include/exclude by regex pattern string. #24
base: groovy-1.8
Are you sure you want to change the base?
Conversation
The regex pattern is matched against the simple name of the annotation, spec, or feature. This addresses http://code.google.com/p/spock/issues/detail?id=184 Also added to new_and_noteworthy, and updated javadoc in IncludeExcludeExtension and RunnerConfiguration. Removed an apparently obsolete part of the example from the latter, because it didn't work when I tried it, and there are no specs for it.
+1 |
I've discussed it with @robfletcher and we would like the following changes before it can be accepted:
|
I'll look at this over the weekend. I originally used FQCN, but with regex, the package dots should be escaped, e.g., 'my.package.IntegrationTest', or '*.IntegrationTest', and I didn't like how that looked. Then Grails included Spock, so I couldn't use my own version with this enhancement anymore, so I did what I needed a different way (using my own global extension), and haven't been using this. So, my "new and noteworthy" comment that this is useful in Grails isn't true anymore, unless/until Grails updates its bundled Spock to include this. |
I'm curious, does Grails 3 even use the Spock plugin any more? I haven't done anything with Grails 3 other than taking a brief look. It seems the plugin may be somewhat redundant since the framework is now integrated with Gradle. I may be missing something, though. |
I haven't really looked at Grails 3 yet; I'm still on 2.4.5, which I don't think uses the plugin, just spock-core:0.7-groovy-2.0 directly. |
Besides matching Pattern/String on FQCN, should it behave like the Class criteria with respect to inheritance? The baseClass matching uses isAssignableFrom(), but pattern matching like that would need to iterate up the superclasses/interfaces(/traits?). |
Hm, you could use Class.forName() with the appropriate try/catch and then use the existing matching method. We should have access to the class at that point. |
Are you suggesting that it try to get a Class based on the Pattern/String, i.e., if it is literally the FQCN, in addition to regex matching? I wonder if Spock's Classloader will really have access to the class at that point, when it wasn't available for a Class literal in the config stage. I guess it wouldn't hurt to try, though. |
As I said before we have three types of matchers:
The classloader should have access to the class in the |
I don't see the original issue on Grails 3.0.2 or 3.0.3. They use spock-core:1.0-groovy-2.4, but apparently load SpockConfig.groovy with a classpath that includes classes under src/test and src/main. So, is there still any use case for SpockConfig with String instead of Class Object? Or, should this PR add only Pattern? |
Please consider adding this to Spock. You mentioned that it would be good to do.
The regex pattern is matched against the simple name
of the annotation, spec, or feature. This addresses
http://code.google.com/p/spock/issues/detail?id=184
Also added to new_and_noteworthy, and updated javadoc in
IncludeExcludeExtension and RunnerConfiguration. Removed an apparently
obsolete part of the example from the latter, because it didn't work
when I tried it, and there are no specs for it.
I would have liked to use GrailsTestTargetPattern with its AntPathMatcher,
but that seemed out of scope for Spock.