验尸单元测试 [英] Post-mortem unit testing

查看:98
本文介绍了验尸单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git进行版本控制,并使用QUnit进行单元测试。有时候,我发现我的软件中有一个错误,该错误在过去的版本中不存在。我很容易为这个bug编写一个单元测试。



考虑到单元测试,我可以轻松过去所有过去的提交,并用该单元测试构建测试,以便我可以确定是哪个提交导致了破坏?

使用 git bisect
解决方案 c $ c>,请参阅此页面



由于您正在测试JavaScript,因此您可能必须手动运行测试并运行 git bisect good git bisect bad 视情况而定。但是,如果您可以从命令行运行单元测试,那么您可以使用 git bisect run 来让Git重复执行测试并自动跟踪错误提交:

  $ git bisect run my-script.sh 

这是第一次看到它时的纯粹魔法! : - )

I do version control with Git, and unit testing with QUnit. Sometimes I find a bug in my software that was not present in a past version. It's easy for me to write a unit test specifically for that bug.

Given that unit test, can I easily go trough all my past commits and test the build with that unit test, so that I can pinpoint which commit caused the breakage?

解决方案

Use git bisect for this, please see this page.

Since you're testing JavaScript, you will probably have to run the tests by hand and run git bisect good and git bisect bad as appropriate. However, if you can run your unit test from the command line, then you can use git bisect run to have Git execute the test repeatedly and track down the faulty commit automatically:

$ git bisect run my-script.sh

That's pure magic the first time you see it! :-)

这篇关于验尸单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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