当前位置:网站首页>Go Land no tests were Run: FMT cannot be used. Printf () & lt; BUG & gt;
Go Land no tests were Run: FMT cannot be used. Printf () & lt; BUG & gt;
2022-06-30 05:04:00 【Zen et art de la programmation informatique】
Description du problème:
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)
}
}Résolution de problèmes:
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
边栏推荐
- Approaching history, introduction to the London Guard Museum
- Solution to the 292 week match of Li Kou
- Detailed explanation of sorting sort method of JS array
- Writing unityshader with sublimetext
- harbor api 2.0查询
- Recommended cultural landmarks of these tourist attractions in Bangkok
- Passing values between classes using delegates and events
- Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
- Unreal 4 unavigationsystemv1 compilation error
- Chapter 10 of OpenGL super classic (7th Edition) calculation shader
猜你喜欢

Winter vacation parent-child tour, these new york attractions are not only fun but also knowledge

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

Generate a slice of mesh Foundation

Unreal 4 unavigationsystemv1 compilation error

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

Create a simple battle game with photon pun

Records of problems encountered in unity + hololens development

Royal Albert Hall, a popular landmark in London

Force buckle 27 Removing Elements

Redis cluster concept
随机推荐
Unity3d realizes Google Digital Earth
Force buckle 59 Spiral matrix II
Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
Nestjs入门和环境搭建
0 basic unity course. Bricklaying
The difference between SVG and canvas
z-index属性在什么情况下会失效?
The golden deer, a scenic spot in London -- a sailing museum that tells vivid sailing stories
Singapore parent-child tour, these popular attractions must be arranged
力扣977. 有序数组的平方
PWN入门(2)栈溢出基础
Solution to Autowired annotation warning
JPA composite primary key usage
Unity automatic pathfinding
Chapter 9 of OpenGL super classic (version 7): fragment processing and frame buffering
Unreal 4 learning notes - set player birth point
Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
Brew install NVM command not found solution
Ripple effect of mouse click (unity & shader)
Unity ontriggerenter does not call