当前位置:网站首页>Golan no tests were run: fmt Printf() < BUG>
Golan no tests were run: fmt Printf() < BUG>
2022-06-30 05:05:00 【Zen and the art of computer programming】
Problem description :
I have a method that I am testing, and everything seems fine. However, when I run the tests in GoLand, I can see in the output that the tests "PASS" but the test runner says "no tests were run".
Here's the sample method in calculator.go
package calculator
import (
"fmt"
)
type Calculator struct {}
func New() Calculator {
return Calculator{}
}
func (s *Calculator) AddTwoNumbers(num_one, num_two int) int {
fmt.Printf("adding")
return num_one + num_two
}Here's the test in calculator_test.go:
package calculator
import (
"fmt"
"testing"
)
func Test_Calculator_AddTwoNumbers(t *testing.T) {
// Arrange
calculator := New()
// Act
total := calculator.AddTwoNumbers(1,2)
// Assert
if total != 3 {
msg := fmt.Sprintf("total should have been %d but instead was %d", 3, total)
t.Error(msg)
}
}Problem solving :
Instead of fmt.Printf() in AddTwoNumbers try either fmt.Println() or fmt.Printf("foo\n')
The absence of the newline in the output of your AddTwoNumbers method is is causing the format of the test execution outputs to not have each test in a new line. The test runner is not being able to interpret that a test was run. Adding that newline, keeps a clean output.
https://stackoverflow.com/questions/68607771/goland-no-tests-were-run
边栏推荐
- PBR material: basic principle and simple fabrication
- z-index属性在什么情况下会失效?
- Chapter 7 vertex processing and drawing commands of OpenGL super classic (7th Edition)
- Read and save txt files
- Passing values between classes using delegates and events
- 【VCS+Verdi联合仿真】~ 以计数器为例
- 2021-07-29 compilation of Cura in ubantu18.04
- SCM learning notes: interrupt learning
- Deeply understand the function calling process of C language
- Solution to Autowired annotation warning
猜你喜欢

Pit of smoothstep node in shadergraph

力扣27. 移除元素

Redis cluster concept

深度学习------不同方法实现Inception-10

力扣209. 长度最小的子数组

Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor

HTC vive cosmos development - handle button event

Win10 vs2015 compiling curaengine

Generate a slice of mesh Foundation

PS1 Contemporary Art Center, Museum of modern art, New York
随机推荐
Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok
2021-03-16
Unity script life cycle and execution sequence
Spring Festival Tourism Strategy: welcome the new year in Bangkok, Thailand
003-JS-DOM-Attr-innerText
Special folders in unity3d and their meanings
LxC and LXD container summary
Operation file file class method
Recommended cultural landmarks of these tourist attractions in Bangkok
svg和canvas的区别
Postman 做测试的 6 个常见问题
Unity ontriggerenter does not call
Unity3d packaging and publishing APK process
Generate a slice of mesh Foundation
Records of some problems encountered during unity development (continuously updated)
Deeply understand the function calling process of C language
Unity automatic pathfinding
amd锐龙CPU A320系列主板如何安装win7
0 foundation starts self-study unit notes control direction becomes larger
OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO