当前位置:网站首页>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
边栏推荐
- Solution to Autowired annotation warning
- Tensorflow2 of ubantu18.04 X installation
- 2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
- Error about the new version of UE4: unavigationsystemv1:: simplemovetoactor has been deprecated
- z-index属性在什么情况下会失效?
- Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
- One command to run rancher
- Output directory of log files after unity3d packaging
- Unity3d lookat parameter description
- Force buckle 209 Minimum length subarray
猜你喜欢

Win10 vs2015 compiling curaengine

Force buckle 59 Spiral matrix II

Exploration of unity webgl

The golden deer, a scenic spot in London -- a sailing museum that tells vivid sailing stories

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

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

PWN入门(2)栈溢出基础

Unity + hololens2 performance test

QT connecting external libraries

Have a heart beating Valentine's day in Singapore
随机推荐
JPA composite primary key usage
Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
Unity3d Google Earth
Easyrecovery data recovery software recovers my photo and video data two years ago
力扣2049:统计最高分的节点数目
Force buckle 27 Removing Elements
Yolov5 torch installation
LXC 和 LXD 容器总结
Nestjs入门和环境搭建
Unity + hololens publishing settings
Read and save txt files
Chapter 12 pipeline monitoring of OpenGL super classic (version 7)
On mask culling of unity
MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
Parkour demo
力扣704. 二分查找
Photon pun refresh hall room list
Connect() and disconnect() of socket in C #
A must see cruise experience in Bangkok: visit the Mekong River and enjoy the scenery on both sides of the river
SCM learning notes: interrupt learning