-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
Dumping table rows parameter in the report #688
Comments
Hi @fedepaol. I'm assuming that you're talking about
I can see the appeal of always logging the parameters in a |
Thanks @blgm for replying. Yes, I am talking about Our need is to be able to dump the parameters in some way, because they are part of the single row description. We may even want to focus / skip some of them. On one side, the points you are making make a lot of sense (func parameters, structs to big to log), on the other hand it still feels that something is missing because a given parameter is still describing the specific test that entry is referring to. Thanks for the help |
I think it's always worth having a discussion. The place that I'm coming from is that Ginkgo is shared by many projects, and it already quite large and difficult to maintain. Also it's often much harder to write code to solve problems in the general case than is is to solve problems for a specific case. But it's possible that this functionality would be useful to lots of people. To get the discussion going, I think you're trying to do something like this: var _ = Describe("test", func() {
makeEntry := func(input, expected int) TableEntry {
return Entry(
fmt.Sprintf("%d squared should be %d", input, expected),
input,
expected,
)
}
DescribeTable(
"squares",
func(input, expected int) {
Expect(input * input).To(Equal(expected))
},
makeEntry(1, 1),
makeEntry(2, 4),
makeEntry(3, 9),
makeEntry(4, 16),
)
}) Which gives the output (simplified):
Of course I'm probably completely wrong, so I'd be really interested to hear more about what you are trying to do. |
It's UGLY but I could imagine doing this right here: by replacing the again, it's ugly but would work and have the desired effect. Alternatively, we could add an optional "onFailText" to the I can try to find some time to work on either approach. Or if you want to take a crack at it @fedepaol feel free to. |
You got to the point! By having it in the description, we would benefit also of seeing the parameters in the passing tests and we would be able to focus / skip. |
As per the first approach, I was thinking that maybe (and optionally) we could craft a description containing the params (and maybe in some structured way), here https://github.com/onsi/ginkgo/blob/master/extensions/table/table_entry.go#L50 |
Durp - of course, just putting them into the description of the One suggestion - what if rather than have Ginkgo try to figure out how to render the description we replace the signature for
to
and allow the user to either pass in a string (which would run the current behavior) or a function that will be passed |
Having a function would have been my next proposal. I am not 100% sure about having it behaving in a "magic" way, mostly because it would be hard for users to discover it from the api, as opposed to having another version of |
Another version works for me and avoids the magic. There's a lot of magic
in Ginkgo - perhaps avoiding even more is a good idea.
So - a new version of `[FXP]Entry` that accepts a function? SGTM!
…On Mon, Jun 8, 2020 at 12:56 PM Federico Paolinelli < ***@***.***> wrote:
func Entry(description string, parameters ...interface{}) TableEntry
to
func Entry(description interface{}, parameters ...interface{}) TableEntry
and allow the user to either pass in a string (which would run the current
behavior) *or* a function that will be passed parameters and returns a
string. That would give the user control over how to format the string.
Thoughts?
Having a function would have been my next proposal. I am not 100% sure
about having it behaving in a "magic" way, mostly because it would be hard
for users to discover it from the api, as opposed to having another version
of Entry that accepts a function instead of a string.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#688 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEIJFSZUPV54SUH7QARHRLRVUX4LANCNFSM4NYJ5OHA>
.
|
Deal! Expect a PR soon, and thanks! |
This is now in onsi/ginkgo@v1.13.0 |
Hi there, we have a matrix - generated suite of tests, which end up as different table rows of a table.
What we would like to do is to have the different parameters dumped in the test output, shall it be the one on standard output or the junit report.
What is the suggested way to have such behaviour? Is dumping the parameters in the entry description the only way?
Would it make sense to (optionally) dump out the parameters in case of table tests? After all, the parameters are part of what's being tested in that particular row. Is this something you would accept as a change?
The text was updated successfully, but these errors were encountered: