强制重新测试或禁用测试缓存 [英] Force retesting or disable test caching

查看:121
本文介绍了强制重新测试或禁用测试缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:



当我运行相同的两次测试时,第二次运行完全没有完成。结果是第一次运行时缓存的结果。

  PASS 
ok测试人员/ apitests(缓存)

链接

我已经检查过 https://golang.org/cmd/go/#hdr-Testing_flags但是没有cli标志。



问题:

是否有可能强制进行测试,以便始终运行测试而不是缓存测试结果。 解决方案

测试旗文档中介绍了一些选项:



$ ul
  • go clean -testcache :过期所有测试结果

  • 在测试运行中使用不可缓存的标志。习惯用法是使用 -count = 1



  • 也就是说,在您的代码或测试代码中将使缓存的测试结果无效(当使用本地文件或环境变量时也有扩展逻辑),因此您不需要手动使测试缓存失效。


    Problem:

    When I run the same go test twice the second run is not done at all. The results are the cached ones from the first run.

    PASS    
    ok      tester/apitests    (cached)
    

    Links

    I already checked https://golang.org/cmd/go/#hdr-Testing_flags but there is no cli flag for that purpose.

    Question:

    Is there a possibility to force go test to always run test and not to cache test results.

    解决方案

    There are a few options as described in the testing flags docs:

    • go clean -testcache: expires all test results
    • use non-cacheable flags on your test run. The idiomatic way is to use -count=1

    That said, changes in your code or test code will invalidate the cached test results (there's extended logic when using local files or environment variables as well), so you should not need to invalidate the test cache manually.

    这篇关于强制重新测试或禁用测试缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆