Okay so in the first write i gonna to show you how to implementation Unit Testing in Go, absolutely this is very ez to learn. So lets do it.
Create Package
so i created package name is helper, but if you wanna to create another package name it`s not a problem.
Like the examples above, i made function simple named Hello World. if we`re trying to test it, then it should be done with Test.go.
Next, Go has a method (t *testing.T) and then follow the code below.
Result
if we wanna to run this code, we got to the helper folder first.
In above, we create a logic which only contains an error by using the panic function.
In Go, we can perform an error other than panic, we can use t.Fail() and t.FailNow() .
It`s the difference when using t.Fail() and t.FailNow()
First, we change in Hello_World.go
Next, we create other function in Hello_World_test.go
Result :
So we got this, thx for read and sorry for the mistakes, Enjoy.
Top comments (4)
Out of context, but what font is used in the VS Code screenshot? Looks very vintage and would love to use it.
parsinta theme
I think that's the VSCode theme, I was asking about the Font
That’s a package deal