- Distributed Computing with Go
- V.N. Nikhil Anurag
- 152字
- 2021-06-24 18:36:08
Testing in Go
Testing is an important part of programming, whether it is in Go or in any other language. Go has a straightforward approach to writing tests, and in this section, we will look at some important tools to help with testing.
There are certain rules and conventions we need to follow to test our code. They can be listed as follows:
- Source files and associated test files are placed in the same package/folder
- The name of the test file for any given source file is <source-file-name>_test.go
- Test functions need to have the "Test" prefix, and the next character in the function name should be capitalized
In the remainder of this section, we will look at three files and their associated tests:
- variadic.go and variadic_test.go
- addInt.go and addInt_test.go
- nil_test.go (there isn't any source file for these tests)
Along the way, we will introduce any further concepts we might use.
推薦閱讀
- 電腦組裝與系統安裝
- Mastering ElasticSearch
- Kali Linux滲透測試全流程詳解
- vSphere Virtual Machine Management
- Ganglia系統監控
- 深入理解eBPF與可觀測性
- Java EE 8 Design Patterns and Best Practices
- STM32庫開發實戰指南:基于STM32F4
- 嵌入式實時操作系統μC/OS原理與實踐
- Mastering Reactive JavaScript
- Kali Linux 2018:Windows Penetration Testing
- AWS SysOps Cookbook
- Hadoop Real-World Solutions Cookbook
- 15分鐘!畫出我的漫畫角色:賣萌篇
- Docker容器技術與運維