Test Setup & Write your first test in Golang | Go Tests #1

Sdílet
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

Komentáře • 8

  • @dantewhite7659
    @dantewhite7659 Před 3 lety

    thx for the video

  • @thuly27
    @thuly27 Před 2 lety

    Did you end up publishing the 3rd video? Thanks.

  • @uthmaanzakariyya3440
    @uthmaanzakariyya3440 Před 2 lety

    Please do you have any guide on how to customise vim like yours?

  • @nabeelyousafpasha
    @nabeelyousafpasha Před 2 lety

    Respect from Pakistan 🇵🇰

  • @GolderiQ
    @GolderiQ Před 4 lety

    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?

    • @kubucation
      @kubucation  Před 4 lety +1

      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.

    • @GolderiQ
      @GolderiQ Před 4 lety

      kubucation thank you for these informations!