- 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.
推薦閱讀
- SharePoint 2013 應(yīng)用開發(fā)實(shí)戰(zhàn)
- 深入理解eBPF與可觀測(cè)性
- 嵌入式Linux應(yīng)用開發(fā)菜鳥進(jìn)階
- 嵌入式實(shí)時(shí)操作系統(tǒng):RT-Thread設(shè)計(jì)與實(shí)現(xiàn)
- Red Hat Enterprise Linux 6.4網(wǎng)絡(luò)操作系統(tǒng)詳解
- Linux網(wǎng)絡(luò)配置與安全管理
- 從零開始學(xué)安裝與重裝系統(tǒng)
- Learning BeagleBone
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程(Windows 7+MS Office 2010)
- 大規(guī)模分布式系統(tǒng)架構(gòu)與設(shè)計(jì)實(shí)戰(zhàn)
- Java EE 7 Developer Handbook
- Windows網(wǎng)絡(luò)編程(第2版)
- Instant Responsive Web Design
- 深入理解Android:卷III
- Windows10開發(fā)入門經(jīng)典