当前位置:网站首页>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
边栏推荐
- 力扣209. 长度最小的子数组
- 很紧张,第一天做软件测试,需要做什么?
- Some problems encountered in unity steamvr
- Unity3d learning notes-1 (C # learning)
- OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
- How does unity use mapbox to implement real maps in games?
- Unity ontriggerenter does not call
- Unity + hololens publishing settings
- PBR material: basic principle and simple fabrication
- Deep learning ----- different methods to realize inception-10
猜你喜欢

Unity is associated with vs. there is a compiler problem when opening

Some problems encountered in unity steamvr

【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example

Output directory of log files after unity3d packaging

Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok

中文版PyCharm改为英文版PyCharm

Unity realizes rotation and Revolution

Create transfer generation point

Universal Studios Singapore: a good place for a one-day parent-child tour in Singapore

Unity/ue reads OPC UA and OPC Da data (UE4)
随机推荐
Chapter 11 advanced data management of OpenGL super classic (version 7)
Generate a slice of mesh Foundation
Leetcode 180 Consecutive numbers (2022.06.29)
OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
Network communication problem locating steps
LXC 和 LXD 容器总结
National Museum of Singapore - give you spiritual and physical satisfaction
Create transfer generation point
Pit of smoothstep node in shadergraph
产生 BUG 测试人员需要自己去分析原因吗?
Important knowledge points in unity3d
LxC and LXD container summary
[vcs+verdi joint simulation] ~ take the counter as an example
Have a heart beating Valentine's day in Singapore
svg和canvas的区别
Unity dotween plug-in description
Unreal 4 learning notes - set player birth point
Spring Festival Tourism Strategy: welcome the new year in Bangkok, Thailand
JPA composite primary key usage