Test Setup & Write your first test in Golang | Go Tests #1
Vložit
- čas přidán 21. 05. 2024
- New to Golang, but not sure how to get started writing proper unit tests? Or do you simply want to catch up on the possibilities and best practices of tests in Golang? The opinionated language brings a lot of test equipment with it making it very easy for you to write fast and efficient tests. In this first video of the series we're creating a test file and writing our first test.
Thumbnail contains Gopher image by Takuya Ueda ( / tenntenn . Licensed under the Creative Commons 3.0 Attributions license. (creativecommons.org/licenses/b...) - Věda a technologie
thx for the video
Did you end up publishing the 3rd video? Thanks.
Please do you have any guide on how to customise vim like yours?
Respect from Pakistan 🇵🇰
No assertion helper? I guess the Errorf() prints in the "error output 2" and exists implicitly with something like a value superior than 0 to indicate a failed test?
We'll get into assertion helpers later in the series. There are a couple of good third-party ones and it's also easy to build custom ones. But I wanted to start the series with the simplest case without dependencies. Not sure what you mean you mean with "exits implicitly"- but the test runner is a bit more high level than that. At the end of the run it does indeed exit with a non-zero exit code if there were test failures, but it first groups tests results per package. So a single test doesn't directly set the exit code. t.Errorf() is essentially a helper function that does multiple things: log the specified message and mark the test as failed. However, it doesn't actually interrupt the execution of the test, this is something we'll see in more detail in the second video, where we'll learn about a way to explicitly interrupt the execution of a test.
kubucation thank you for these informations!