Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Go in Practice question on CI, deployment and testing

 
Author
Posts: 18
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulations on the book! It looks like a very practical and helpful book for Go developers.

From the contents, I see there is a section on testing. What kinds of tools does the go community have to build generated test reports? Will the build of a go project fail if a test fails or can the developer force that behavior?

Is there a common or best practice for integrating go applications in a CI solution like Jenkins? It seems that if the Jenkins build server has the correct version of go installed that integration with Jenkins should be pretty easy. Is this a common practice in the go community?

Thanks,

Lloyd
 
Author
Posts: 14
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Go toolchain, which includes the compiler, also includes testing and reporting tools. Testing is a first class citizen.

Test files are those that end in _test.go. Files with this ending are skipped when building but included when running the test suite. Test files live alongside application source files.

Tests use the testing package from the standard library. Tests start with Test. For example...



Normal language functionality is used in the tests. In addition to tests like this there are benchmarks, example, and more.

Then there are feature like the code coverage reports. You can read about them in this blog post. This has now been moved into the toolchain and requires no additional feature be installed. There coverage reports can be viewed in HTML or exported to other services like https://coveralls.io/.

It's really common to integrate Go into testing systems. For example, Travis CI has Go support as a first class language. If you have Go installed on a Jenkins server you can test with it. Or, if you want to test against multiple versions you can even use the Docker plugin for Jenkins and use differing versions of the golang image as a base.

Does this help?
 
Lloyd Meinholz
Author
Posts: 18
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That answer is very helpful, thanks for the response. Coming from a Java background, it is interesting (and a great idea) to have so much testing support in the language proper vs. adding on tools.

I like the idea of using golang docker images to be more flexible with go versions.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic