-
Notifications
You must be signed in to change notification settings - Fork 466
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
Adding block listener support #111
Adding block listener support #111
Conversation
Why |
@Fuud thanks for the feedback. Will do some changes when I have time (btw will try to add an Guys, there is little to no action overall on this cool project, is this something that is intended? |
@@ -31,6 +31,11 @@ | |||
void beforeSpec(SpecInfo spec); | |||
|
|||
/** | |||
* Called when a block is reached. |
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.
Wouldn't be useful to have both beforeBlock
and afterBlock
?
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.
Don't have a use case for afterBlock. My current use case for this is to have dinamic reports by resolving the block expression before sending it to the reports listener
I am interested in this functionality. I use Allure reports, before and after Block events would help to create parent step, and the steps inside the block would give more details, if needed. |
What is preventing this to be merged? |
I see several issues:
|
Looks like Fundamentally this is a good idea but the issues @leonard84 raises above are valid. We shouldn't include this in 1.1 at this stage but certainly should consider it after 1.1 final is released & above issues are addressed. |
Meanwhile, I use a simple and ugly, yet functional, workaround. |
Just note that |
Well, but BTW, it is quite easy to avoid the abstract base spec because for people using Spock as well as Geb it would mean several base specs such as ones extending import spock.lang.Specification
class LabelPrinter {
def _(def message) {
println message
true
}
}
Specification.mixin LabelPrinter |
@leonard84 I will have some spare time to work on this in the following 2 weeks.
|
The greatest issue I see is with the rewrites performed by Spock for its mock handling. class Spec extends spock.lang.Specification {
def "simple Test"() {
given: "a simple list"
List subject = Mock()
when: "an element is queried"
def result = subject.get(0)
then: "get is called and hello is returned"
1 * subject.get(_) >> "hello"
result == "hello"
}
} will be transformed into @org.spockframework.runtime.model.FeatureMetadata(name = 'simple Test', ordinal = 0, line = 3,
blocks = [org.spockframework.runtime.model.BlockKind.SETUP['a simple list'],
org.spockframework.runtime.model.BlockKind.WHEN['an element is queried'],
org.spockframework.runtime.model.BlockKind.THEN['get is called and hello is returned']], parameterNames = [])
public void $spock_feature_0_0() {
org.spockframework.runtime.ErrorCollector $spock_errorCollector = new org.spockframework.runtime.ErrorCollector(false)
org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder()
try {
java.util.List subject = this.MockImpl('subject', java.util.List)
this.getSpecificationContext().getMockController().enterScope()
this.getSpecificationContext().getMockController().addInteraction(new org.spockframework.mock.runtime.InteractionBuilder(11, 5, '1 * subject.get(_) >> "hello"').setFixedCount(1).addEqualTarget(subject).addEqualMethodName('get').setArgListKind(true).addEqualArg(_).addConstantResponse('hello').build())
java.lang.Object result = subject.get(0)
this.getSpecificationContext().getMockController().leaveScope()
try {
org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'result == "hello"', 12, 5, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), result) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), 'hello')))
}
catch (java.lang.Throwable throwable) {
org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'result == "hello"', 12, 5, null, throwable)}
finally {
}
this.getSpecificationContext().getMockController().leaveScope()
}
finally {
$spock_errorCollector.validateCollectedErrors()}
} As you can see some of the interaction logic is moved before the |
As usual when introducing Spock to a new team, the question of block label printing during test execution (I am not talking about test report generation here) came up. So I hope it is okay to ask if this PR is still on anyone's radar and if there is a plan how to implement block listener support (including a solution for "and"). See also #538. |
Yes the feature request is still on the radar, this PR will not be the basis for it though (reasons listed above). Unfortunately, we can't transform it into an issue, as the comments are still valid. |
I also would require this feature, is someone already working on the comments fixes? |
This looks interesting, is there anyway i can add screenshot images as well at block level along with these messages? |
@vanjimohan, you should not quote complete messages. As for screenshots, this is kind of off-topic here as we are talking about Spock, not Geb. You are hijacking a thread. But why don't you just try? In principle you can add any code into the |
Any chance of this making it into 2.0 (or 1.3.x)? |
Pretty unlikely as 2.0 is already released and there will not be any further 1.3.x release. |
Sad. This seems like a needed feature in order to generate proper detailed reports. |
Why would a useful and potentially popular feature like this depend on a PR? And why would a bad or suboptimal PR block a feature from being implemented from scratch? Probably, a maintainer can implement this in a better way which would not cause a PR to sit there and rot in the first place. It might not have the highest priority, if there is more important work in the backlog - no problem with that. But to say, a feature is unlikely to be implemented, just because there is no normal user capable of implementing it herself, strikes me as an odd statement. IMO, less useful stuff has been implemented and released, while this one here, bearing potential for a whole new class of extensions, remains untouched because no external contributor so far could do it right. Hmm... 🤔 |
You either got me wrong or are twisting my words in my mouth. |
Well, actually I care about the feature, not the PR itself :) |
I never had any intention of twisting anyone's words in their mouths, but interpreted your statement to the best of my understanding. So that kind of innuendo is not going to make anything better. Now that you expressed yourself more unambiguously, I understand better - and so do others reading this, too, I suppose. So thank you for the clarification. |
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.
Can someone please look into these changes and take ahead. If it is merged then it will be good for reporting purpose.
Block listener support will be implemented via #1575 |
Hey,
I've added a pull request that adds when/then block notification support.
I'm planning to use them internally for dynamic report generation (descriptions with variable expansion) by customizing the existing support.
Is this something that interests the community ? If yes, I can allocate some time to add implement any feedback that comes
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)