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

Ginkgo should run tests from both the "name" package and "name_test" package #31

Closed
tjarratt opened this issue Feb 5, 2014 · 5 comments

Comments

@tjarratt
Copy link
Contributor

tjarratt commented Feb 5, 2014

I was very surprised to discover that Ginkgo will only run the tests that are defined in the same package as the suite_test. Seems like a bug, but I would also accept that this is a feature (because it forces you to write your tests in the name_test package.

Alternatively, if this is hard to solve, a warning would be very nice.

@onsi
Copy link
Owner

onsi commented Feb 5, 2014

I just tried this on my laptop with a simple example and it worked. Can you
point me to a code example that's failing for you?

Onsi

On Tuesday, February 4, 2014, Tim Jarratt notifications@github.com wrote:

I was very surprised to discover that Ginkgo will only run the tests that
are defined in the same package as the suite_test. Seems like a bug, but I
would also accept that this is a feature (because it forces you to write
your tests in the name_test package.

Alternatively, if this is hard to solve, a warning would be very nice.

Reply to this email directly or view it on GitHubhttps://github.com//issues/31
.

@tjarratt
Copy link
Contributor Author

tjarratt commented Feb 5, 2014

I took a closer look and the behavior was a little surprising. It appears to work for some cases, but not others.

cloudfoundry/cli@c197cd5 seems to exhibit this behavior for domain_test.go in the cf package

@onsi
Copy link
Owner

onsi commented Feb 7, 2014

Methinks this is because the only file in the cf_test package is cf_suite_test.go itself and cf_suite_test.go does not reference any of the cf package files at all.

A simple fix for this might be to add

import (
    . "github.com/onsi/ginkgo"
    . "github.com/onsi/gomega"
        _ "cf"
    "testing"
)

to the cf_suite_test.go file (this could be made the default in the ginkgo bootstrap command, we'd also need to add it to ginkgo convert). This would import the cf package purely for its side effects (in this case, the side effects involve registering the ginkgo tests in that package!)

@tjarratt
Copy link
Contributor Author

tjarratt commented Feb 7, 2014

I wasn't aware you could import a package as _. That's ... interesting.

With that information, this doesn't sound like a real bug per se. It's already conventional to put your tests in a separate package from your package under test, so I would be willing to chalk this up to user error and consider this issue closed.

@onsi
Copy link
Owner

onsi commented Feb 7, 2014

Coo :)

Yeah... _ is interesting.............

On Feb 6, 2014, at 9:47 PM, Tim Jarratt notifications@github.com wrote:

I wasn't aware you could import a package as _. That's ... interesting.

With that information, this doesn't sound like a real bug per se. It's already conventional to put your tests in a separate package from your package under test, so I would be willing to chalk this up to user error and consider this issue closed.


Reply to this email directly or view it on GitHub.

@onsi onsi closed this as completed Feb 7, 2014
xjh1996 pushed a commit to xjh1996/ginkgo that referenced this issue Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants