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

feat: table tests should point to test code #635

Closed
wants to merge 2 commits into from

Conversation

sethp-nr
Copy link

Previously, ginkgo would identify the code locations of the failing
Entry or DescribeTable as part of the
ginkgo/extensions/table/table_entry.go or
ginkgo/extensions/table/table.go files, respectively.

When there are a large number of table entries, it is more desirable to
provide the line numbers of the table and table entry directly to
facilitate jumping to the relevant section of the test code.

Fixes #515

Previously, ginkgo would identify the code locations of the failing
Entry or DescribeTable as part of the
ginkgo/extensions/table/table_entry.go or
ginkgo/extensions/table/table.go files, respectively.

When there are a large number of table entries, it is more desirable to
provide the line numbers of the table and table entry directly to
facilitate jumping to the relevant section of the test code.

Fixes onsi#515
@ansd
Copy link
Collaborator

ansd commented Apr 18, 2020

Hey @sethp-nr,

Thanks a lot for your PR.
@dpb587-pivotal and I had a look at it last week.
We like it, the changes are good and working, in particular the integration tests!
However, there are a couple of points which I'm going to provide in-line review.
Inspired by your PR, I created #666.
I would be happy about your feedback / thoughts.

@ansd ansd self-requested a review April 18, 2020 19:34
globalSuite.PushContainerNode(text, body, flag, codeLocation)
return true
}

Copy link
Collaborator

@ansd ansd Apr 18, 2020

Choose a reason for hiding this comment

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

Although exporting these two functions works, it's not ideal. Every user which imports github.com/onsi/ginkgo will have access to these functions although these are only internal helper functions.


Ω(output).Should(
ContainSubstring("failing_table_tests/failing_table_tests_test.go:12"),
"point to the failing assertion")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's cool that you provide the optional test description given the complexity of the test.

@@ -12,13 +14,15 @@ TableEntry represents an entry in a table test. You generally use the `Entry` c
type TableEntry struct {
Description string
Parameters []interface{}
Pending bool
Focused bool
Flag types.FlagType
Copy link
Collaborator

@ansd ansd Apr 18, 2020

Choose a reason for hiding this comment

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

I also first thought it's a good idea to use the single Flag field instead of Pending and Focused. I'm not sure since I haven't written the original code but it looks like the Pending and Focused fields are there on purpose since they are exported to the user?
Also, if we do this change, we will break all users who construct a TableEntry directly (rather than using the (F/P/X)Entry constructors). Looking at the go docs for TableEntry, they state

TableEntry represents an entry in a table test. You generally use the Entry constructor.

Although I've not seen people constructing the TableEntry directly, some people might do in which case we would break them with these changes.

Focused bool
Flag types.FlagType

// TODO: what if this isn't set?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point. I don't have a clear answer. In #666 I just print the surrounding DescribeTable whenever it's not set.

} else {
ginkgo.It(t.Description, body)
}
}, t.Flag, t.codeLocation, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The last 0 argument does not look correct?
You pass it further to ExplicitItNode where it becomes the timeout for PushItNode which would result in a timeout of 0 seconds here rather than the default timeout of 1 second defined here.

@sethp-nr
Copy link
Author

That's all great feedback, thanks! It looks like your PR #666 captured all the valuable parts to me, let's close this in favor of that one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct code location for table driven tests
2 participants