doubaisui2526 2015-10-11 18:39
浏览 76

使用Go的测试包,可以测试打印到os.Stdout的内容(如果部分输出不确定)?

I'm making a golang cli app using the github.com/codegangsta/cli package

I'm trying to test my app by calling app.Run(args) with invalid arguments. When running go test the output of the invalid arguments test is almost all deterministic except the USAGE section refers to go-build435629639 as part of the name of the executable (i.e. os.Args[0]) which is different each time.

Can I direct the output from app.Run into another io.writer without changing the cli package?

Can Examples with output specified be forced to skip over certain lines (or to only check the first line of output)?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)