问题描述:

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 calculatorimport ("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 calculatorimport ("fmt""testing"
)func Test_Calculator_AddTwoNumbers(t *testing.T) {// Arrangecalculator := New()// Acttotal := calculator.AddTwoNumbers(1,2)// Assertif total != 3 {msg := fmt.Sprintf("total should have been %d but instead was %d", 3, total)t.Error(msg)}
}

问题解决:

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


http://www.taodudu.cc/news/show-2563762.html

相关文章:

  • No tests were found
  • 单元测试,我有话说(No tests to run. No tests were executed)
  • Ran 0 tests in 0.000s
  • no tests ran in 0.03 seconds
  • Django 入门:tests.py
  • riscv-tests的使用
  • postman tests获取cookie
  • postman使用之Tests使用
  • django tests 小结
  • Django测试文件——tests.py
  • postman:Tests模块之断言
  • iOS 单元测试 Tests 和 UITests
  • postman tests
  • Ansible Tests详解
  • postman tests脚本
  • postman tests实例记录,常用测试结果验证及使用技巧
  • 单片机的俄罗斯方块游戏设计
  • 俄罗斯方块游戏的算法
  • PHP俄罗斯方块游戏代码,俄罗斯方块游戏,俄罗斯方块游戏编程代码
  • 俄罗斯方块c语言程序方案设计,c语言俄罗斯方块游戏程序方案设计书报告.doc
  • 基于stm32f103的俄罗斯方块游戏
  • 基于Java的俄罗斯方块游戏的设计与实现(含源文件)
  • html俄罗斯方块游戏代码,史上最短小精悍的javascript编写的俄罗斯方块游戏,仅仅60行代码...
  • 软件设计实战:基于Java的俄罗斯方块游戏【完整版】
  • 基于Vue的俄罗斯方块游戏设计与实现
  • linux俄罗斯方块游戏
  • 基于51单片机的俄罗斯方块游戏
  • 俄罗斯方块游戏设计
  • 俄罗斯方块游戏开发教程1:整体流程
  • VS编程俄罗斯方块游戏

GoLand No Tests Were Run : 不能使用 fmt.Printf() BUG相关推荐

  1. Jmeter-Maven-Plugin高级应用:Selecting Tests To Run

    地址:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration Selecting ...

  2. fmt.Println、fmt.Printf、fmt.Sprintf、fmt.Sprintln

    fmt包实现了格式化的I/O. 1.fmt.Println: 用默认的类型格式将传入的参数写到标准输出 参数;字符串和变量之间用逗号间隔, 输出:用空格间隔 2.fmt.Printf: 用占位符将传入 ...

  3. Go语言fmt.Printf使用指南(占位符总结)

    本文整理了Go语言的标准输出流(fmt.Printf)在打印到屏幕时的格式化输出操作. 在这里按照占位符将被替换的变量类型划分,更方便查询和记忆. 总结 1.1 General(通用占位符) 占位符 ...

  4. go语言 格式化输出fmt.Printf()使用大全

    [简介] fmt 包实现了格式化 I/O 函数,类似于 C 的 printf 和 scanf.格式"占位符"衍生自 C,但比 C 更简单. [打印] 占位符: [一般] %v 相应 ...

  5. Go 打印结构体(struct)信息:fmt.Printf(“%+v“, user)

    转自:打印 Go 结构体(struct)信息:fmt.Printf("%+v", user) package mainimport "fmt"// 用户 typ ...

  6. Go语言fmt.Sprintf、fmt.Printf(格式化输出)

    fmt.Printf fmt.Printf在程序中使用%f来格式化所需的值 看起来我们的值被四舍五入到了一个合理的数.但小数点后仍显示了6位,这对我们当前的需要来说实在是太多了. 对于这种情况,格式化 ...

  7. golang fmt.Sprintf fmt.Fprintf fmt.Printf

    package main import "fmt" import "os" type point struct {x, y int } func main() ...

  8. Go语言fmt.Printf使用指南

    Go语言fmt.Printf使用指南 fmt标准库是我们在学习Go语言过程中接触最早最频繁的一个了,本文介绍了fmtb包的一些常用函数. fmt fmt包实现了类似C语言printf和scanf的格式 ...

  9. Go语言中的fmt.Print, fmt.Printf, fmt.Println的区别和使用场景

    Go语言中的fmt.Print, fmt.Printf, fmt.Println的区别和使用场景 fmt 包的介绍 fmt.Print === 原样输出 fmt.Printf === 格式输出 fmt ...

  10. Go 学习笔记(37)— 标准命令(go build 跨平台编译、交叉编译、go clean、go run、go fmt、go install、go get)

    1. 标准命令简述 Go 本身包含来大量用于处理 Go 程序的命令和工具. 命令 作用 build 用于编译指定的代码包或 Go 语言源码文件.命令源码文件会被编译成可执行文件,并存放到命令执行的目录 ...

最新文章

  1. 谈谈Team Foundation Server Proxy
  2. Oracle表空间创建的sql
  3. 图像识别中卷积神经网络“卷积”的作用
  4. python读取raw数据文件_Python 读写文件中数据
  5. MySQL高级 - 内存优化 - 优化原则
  6. 高等数学下-赵立军-北京大学出版社-题解-练习8.5
  7. [BZOJ1444]有趣的游戏(AC自动机+矩阵乘法)
  8. org.springframework.http.converter.HttpMessageNotWritableException:
  9. 计算机电源插头有哪几种,盘点电连接器常见的使用类型
  10. 如果把Python代码写成这样子就太难看了
  11. 【血型】+【星座】准到吓人
  12. 双击桌面计算机删除,笔记本电脑点击图标自动删除怎么办
  13. 京东青龙面板撸豆_搭建环境流程
  14. c语言常用延时程序,新手常用单片机延时程序
  15. Jsp显示应用外服务器的图片,jsp显示服务器的绝对路径图片
  16. 送你一份迷你书,全面了解如何做好大促技术备战
  17. MATLAB提取txt文本文档中特定关键字后的数字信息
  18. 几个python运维脚本
  19. 文储研习社第11期 | DAO的前世今生
  20. Python:【4】利用讯飞开放平台实现语音识别

热门文章

  1. mybatis 标签中prefix,suffix,prefixOverrides,suffixOverrides作用
  2. python(2): If/for/函数/try异常/调试/格式输出%
  3. cocos2d-x中制作动画
  4. CSS基础教程(上)
  5. linux幻灯片制作软件,Marp(代码制作幻灯片软件)
  6. OpenCV-白平衡(灰度世界算法)
  7. iphone,ipad尺寸汇总
  8. 会议纪要模板----正式文档
  9. dataFrame(DF)将数据插入ES时报错 org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect E
  10. 数据仓库是什么?和数据库有何区别?