当前位置:网站首页>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
边栏推荐
- UnityEngine. JsonUtility. The pit of fromjason()
- How to install win7 on AMD Ruilong CPU A320 series motherboard
- brew安装nvm报nvm command not found解决方案
- Recommended cultural landmarks of these tourist attractions in Bangkok
- Pytorchcnn image recognition and classification model training framework
- Unity realizes rotation and Revolution
- UE4 method of embedding web pages
- Unity script life cycle and execution sequence
- Marvel fan welfare: Singapore Madame Tussauds Wax Museum Marvel 4D experience Museum
- OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
猜你喜欢

PBR material: basic principle and simple fabrication

Connect() and disconnect() of socket in C #

Preorder traversal of Li Kou 589:n fork tree

Easyrecovery data recovery software recovers my photo and video data two years ago

【VCS+Verdi联合仿真】~ 以计数器为例

PS1 Contemporary Art Center, Museum of modern art, New York

Unreal 4 unavigationsystemv1 compilation error

Unity packaging failure solution

Malignant bug: 1252 of unit MySQL export

Autowired注解警告的解决办法
随机推荐
Unity is associated with vs. there is a compiler problem when opening
Unity multiple UI page turning left and right
Unity application class and data file path
How to install win7 on AMD Ruilong CPU A320 series motherboard
Yolov5 torch installation
Unity ontriggerenter does not call
2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
Chapter 8 primitive processing of OpenGL super classic (version 7)
Four methods of unity ugui button binding events
Unity enables simple music visualization
Parkour demo
Li Kou 2049: count the number of nodes with the highest score
Chapter 11 advanced data management of OpenGL super classic (version 7)
2021-03-16
PWN入门(2)栈溢出基础
Unity + hololens2 performance test
PBR material: basic principle and simple fabrication
Tcp/ip protocol details Volume I (Reading Guide)
Unity3d packaging and publishing APK process
QT connecting external libraries