当前位置:网站首页>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
边栏推荐
- Pytorchcnn image recognition and classification model training framework
- Li Kou 2049: count the number of nodes with the highest score
- PWN入门(2)栈溢出基础
- Important knowledge points in unity3d
- Check London attractions suitable for parents and children in winter vacation
- Singleton mode in unity
- Basic operations of Oracle data
- Unreal 4 unavigationsystemv1 compilation error
- Steamvr causes abnormal scene camera
- Unity automatic pathfinding
猜你喜欢

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

Harbor API 2.0 query

Network communication problem locating steps

Procedural animation -- inverse kinematics of tentacles

Output directory of log files after unity3d packaging

Meet in Bangkok for a romantic trip on Valentine's Day

Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)

Writing unityshader with sublimetext

Check London attractions suitable for parents and children in winter vacation

Unreal 4 unavigationsystemv1 compilation error
随机推荐
Ripple effect of mouse click (unity & shader)
LxC and LXD container summary
Writing unityshader with sublimetext
Unity is associated with vs. there is a compiler problem when opening
Unity lens making
JS 数组的排序 sort方法详解
Photon pun refresh hall room list
Unity3d packaging and publishing APK process
003-JS-DOM-Attr-innerText
Create transfer generation point
Chapter 10 of OpenGL super classic (7th Edition) calculation shader
One command to run rancher
UnityEngine. JsonUtility. The pit of fromjason()
【VCS+Verdi聯合仿真】~ 以計數器為例
Royal Albert Hall, a popular landmark in London
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
2021-03-16
Win10 vs2015 compiling curaengine
很紧张,第一天做软件测试,需要做什么?
Chapter 7 vertex processing and drawing commands of OpenGL super classic (7th Edition)