onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.37k stars 660 forks source link

New to ginkgo #231

Closed JC1738 closed 8 years ago

JC1738 commented 8 years ago

I am following the first couple of steps at: http://onsi.github.io/ginkgo/

$ cd path/to/books $ ginkgo bootstrap

work fine, run go test, got --- PASS: TestBootstrap (0.00 seconds) PASS ok books 0.019s

But when I do

$ ginkgo generate book

And then run go test

Get:

no buildable Go source files in /Users/JC/go/src/github.com/JC/books

Not sure why this step doesn't seem to work.

Thanks,

Jim

robdimsdale commented 8 years ago

@JC1738 I follow the steps and I get the same issue as you. This is because there isn't anything to test.

The docs are testing an example package books with various methods and objects. To get past your immediate issue you could create that package:

echo "package book" > book.go

and then re-run the steps:

ginkgo # or go test

Failed to compile books:

# github.com/JC/books_test
book_test.go:4: imported and not used: "github.com/JC/books"
book_test.go:7: imported and not used: "github.com/onsi/gomega"

Ginkgo ran 1 suite in 919.252328ms
Test Suite Failed

This is a different error, and it is because ginkgo imports some packages by default.

Generally those docs won't pass tests if you try to run them because they're only giving examples of the tests - there is no corresponding production code.

If you feel the docs need examples of the objects under test, I'd be happy to merge that PR

onsi commented 8 years ago

yep, what @robdimsdale said - apologies for this @JC1738

The doc examples are meant as illustrations not copy-paste examples. If that would be valuable I think a simple GitHub repo with Ginkgo and Gomega examples and patterns might be the way to go.

Could be a cool community supported thing to do if someone had the bandwidth and/or interest...

robdimsdale commented 8 years ago

It's been a couple of weeks without any response to this issue, so I'm closing it now. @JC1738 if you have further questions or are interested in submitting a PR to update the docs please feel free to open a new issue.

Thanks, Rob

davecb commented 7 years ago

@onsi I always run the worked example whenever someone proposes something to me, to see if it works. I'm an old guy, and I've wasted a lot of my life on stuff that looks cool, but doesn't actually do anything, so I expect examples to work. Alas, while step 1 works, step 2 fails and doesn't produce the output you illustrate. It probably worked once, but it doesn't any more.

That isn't going to look very credible to to me or anyone else who tries the package (;-()

All the (obvious!) effort you put into documenting it has just gone to waste, and prospective users have silently gone elsewhere.

As it happens, I found another worked example you wrote at https://blog.gopheracademy.com/advent-2013/ginkgo/ in 2013, which I'll give a try, but you really really should fix the bug in "Your First Test". After all, it's likely to be the first thing all your readers try!

--dave

onsi commented 7 years ago

Hey @davecb - yes the example in the documentation is written to express what a Ginkgo test looks like not as a literal worked example.

I'm not confident adding something to the documentation would be effective. I think it would be best to have an example project and test suite that ships with Ginkgo (that is simpler than Ginkgo's own test suite of course) and simply point to it from the documentation. Thoughts?

AswathyAshokan commented 6 years ago

i have also facing the same issue as posted by jc1738. i followed the steps of @robdimsdale but getting the same error "no buildable Go source files in /usr/lib/go-1.8/Projects/mirafra/books"

marcotorre commented 6 years ago

A bit late to this forum, but if you still weren't able to create the book.go code, you can view what I have here.