FAQ
Does anyone have any advice for setting up testing for an entire app? I
have tests written for a lot of the submodules but running them all
individually isn't really an option. I'm using gocheck since it has
fixtures so thats nice. What I'd really like is something where I can run a
single script/command and it will run all the tests in the app. Being able
to define some setup and teardown (database setup, config loading, etc) for
the entire process would be nice.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Nate Finch at Apr 4, 2014 at 9:38 pm
    Go test ./... Will run everything in subdirectories. if you need common setup and teardown, you can embed a common suite in all your test suites, however I don't think there's a way to have a single setup run before all other packages and a teardown run after all other packages. Go testing is inherently by package (since there's no true linking between packages). Does it really take that long to create a tiny test DB? Juju creates multiple mongodb instances for it's tests, and it's pretty quick.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Whatcott at Apr 5, 2014 at 5:40 am
    GoConvey <https://github.com/smartystreets/goconvey> will run all your
    tests for you, every time you save a file in your project. Just start it at
    the root of your project and it will report all results (of testing all
    packages in your project) to your web browser pointed at 127.0.0.1:8080 (or
    wherever you specify using the command line flags).

    $ go get -t github.com/smartystreets/goconvey
    $ cd <your-project-root>
    $ $GOPATH/bin/goconvey
    (open your browser to 127.0.0.1:8080 and start coding)


    Any modification to existing files or deletion/creation of a file causes
    GoConvey to re-run your entire test suite. GoConvey introduces an alternate
    way to compose the body of test functions with a lot of convenient
    "assertion" methods but that's completely optional. It is perfectly capable
    of running traditional go test functions and report the results to the
    browser. I use it all the time when I'm coding as it's really streamlined
    my workflow, especially for large projects.

    Disclosure: I'm one of the authors.

    Mike

    On Friday, April 4, 2014 2:44:04 PM UTC-6, Travis Beauvais wrote:

    Does anyone have any advice for setting up testing for an entire app? I
    have tests written for a lot of the submodules but running them all
    individually isn't really an option. I'm using gocheck since it has
    fixtures so thats nice. What I'd really like is something where I can run a
    single script/command and it will run all the tests in the app. Being able
    to define some setup and teardown (database setup, config loading, etc) for
    the entire process would be nice.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Travis Beauvais at Apr 5, 2014 at 9:43 pm
    Thanks for your input.

    Michael, I checked out GoConvey and it looks nice but still doesn't really
    work for my situation where I have dozens of subpackages and I want to run
    an entire suite of tests over all packages in the app. I do like the API to
    though.

    Here is what I currently thinking.

    If my binary is run with a tests flag, rather that run as normal (http
    server), it runs tests. I've taken out the matchString() function from the
    go test tool. In the app I have a map[string]fun(*testing.T) with all tests
    defined. When the binary is run with that flag, I iterate through that map
    while building a slice of testing.InternalTest. Then I call testing.Main()
    with that slice. Now I can do whatever setup or teardown I need to before
    or after the call to testing.Main().

    By doing this I lose the ability to use go test since I can't put my tests
    in "_test.go" files any more. I am also at the mercy of any changes to core
    lib since matchString() from the go tool is not public and the
    testing.Main() function and testing.InternalTest type are not meant to be
    used externally. In my opinion these are low risk and is giving me a very
    flexible testing environment.
    On Friday, April 4, 2014 10:40:00 PM UTC-7, Michael Whatcott wrote:

    GoConvey <https://github.com/smartystreets/goconvey> will run all your
    tests for you, every time you save a file in your project. Just start it at
    the root of your project and it will report all results (of testing all
    packages in your project) to your web browser pointed at 127.0.0.1:8080(or wherever you specify using the command line flags).

    $ go get -t github.com/smartystreets/goconvey
    $ cd <your-project-root>
    $ $GOPATH/bin/goconvey
    (open your browser to 127.0.0.1:8080 and start coding)


    Any modification to existing files or deletion/creation of a file causes
    GoConvey to re-run your entire test suite. GoConvey introduces an alternate
    way to compose the body of test functions with a lot of convenient
    "assertion" methods but that's completely optional. It is perfectly capable
    of running traditional go test functions and report the results to the
    browser. I use it all the time when I'm coding as it's really streamlined
    my workflow, especially for large projects.

    Disclosure: I'm one of the authors.

    Mike

    On Friday, April 4, 2014 2:44:04 PM UTC-6, Travis Beauvais wrote:

    Does anyone have any advice for setting up testing for an entire app? I
    have tests written for a lot of the submodules but running them all
    individually isn't really an option. I'm using gocheck since it has
    fixtures so thats nice. What I'd really like is something where I can run a
    single script/command and it will run all the tests in the app. Being able
    to define some setup and teardown (database setup, config loading, etc) for
    the entire process would be nice.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Whatcott at Apr 5, 2014 at 10:10 pm
    Glad you've solved it. Good luck.
    On Saturday, April 5, 2014 3:43:41 PM UTC-6, Travis Beauvais wrote:

    Thanks for your input.

    Michael, I checked out GoConvey and it looks nice but still doesn't really
    work for my situation where I have dozens of subpackages and I want to run
    an entire suite of tests over all packages in the app. I do like the API to
    though.

    Here is what I currently thinking.

    If my binary is run with a tests flag, rather that run as normal (http
    server), it runs tests. I've taken out the matchString() function from the
    go test tool. In the app I have a map[string]fun(*testing.T) with all tests
    defined. When the binary is run with that flag, I iterate through that map
    while building a slice of testing.InternalTest. Then I call testing.Main()
    with that slice. Now I can do whatever setup or teardown I need to before
    or after the call to testing.Main().

    By doing this I lose the ability to use go test since I can't put my tests
    in "_test.go" files any more. I am also at the mercy of any changes to core
    lib since matchString() from the go tool is not public and the
    testing.Main() function and testing.InternalTest type are not meant to be
    used externally. In my opinion these are low risk and is giving me a very
    flexible testing environment.
    On Friday, April 4, 2014 10:40:00 PM UTC-7, Michael Whatcott wrote:

    GoConvey <https://github.com/smartystreets/goconvey> will run all your
    tests for you, every time you save a file in your project. Just start it at
    the root of your project and it will report all results (of testing all
    packages in your project) to your web browser pointed at 127.0.0.1:8080(or wherever you specify using the command line flags).

    $ go get -t github.com/smartystreets/goconvey
    $ cd <your-project-root>
    $ $GOPATH/bin/goconvey
    (open your browser to 127.0.0.1:8080 and start coding)


    Any modification to existing files or deletion/creation of a file causes
    GoConvey to re-run your entire test suite. GoConvey introduces an alternate
    way to compose the body of test functions with a lot of convenient
    "assertion" methods but that's completely optional. It is perfectly capable
    of running traditional go test functions and report the results to the
    browser. I use it all the time when I'm coding as it's really streamlined
    my workflow, especially for large projects.

    Disclosure: I'm one of the authors.

    Mike

    On Friday, April 4, 2014 2:44:04 PM UTC-6, Travis Beauvais wrote:

    Does anyone have any advice for setting up testing for an entire app? I
    have tests written for a lot of the submodules but running them all
    individually isn't really an option. I'm using gocheck since it has
    fixtures so thats nice. What I'd really like is something where I can run a
    single script/command and it will run all the tests in the app. Being able
    to define some setup and teardown (database setup, config loading, etc) for
    the entire process would be nice.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 4, '14 at 8:44p
activeApr 5, '14 at 10:10p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase