---
# System prepended metadata

title: Go Testing
tags: [golang]

---

# Go Testing
###### tags: `golang`

[TOC]

# Go Test Introduction
Go Language already has a third party for testing purpose. 
## How to make one?
Just make a new file and the package must be name **_test**.

**Function Test:**
You will notice that it uses a **t *testing.T** parameter, this one will be importing **testing** after saving the file. This one can be used to print different fail/error logs.

You will notice there is a button **run test|debug test** on the up part of the function. By clicking on it you can easily debug/run test.

```go=
func TestBestMascot(t *testing.T) {
	if mascot.BestMascot() != "Rabbit" {
		t.Fatal("Wrong mascot!")
	}
}
```

![](https://i.imgur.com/2XKNRF5.png)