维持单元测试很困难.我确信我们都经历过一个时刻,对被测系统的看似微小的变化导致数十个单元测试失败.有时这些故障揭示了SUT中的错误,但通常测试已经过时,不再反映SUT的正确行为.在这些情况下,有必要修复损坏的测试.
你遇到过这种情况吗?经常发生吗?你介绍了什么变化以及失败是如何表现出来的?你修复了破损的测试或者只是删除了它们吗?如果是前者,怎么样?如果是后者,为什么?对失败的恐惧如何影响您编写测试的愿望?
我还想找到破损测试的具体例子.您是否知道任何以导致测试失败的方式发展的开源应用程序?
有没有办法通过SSH将Mercurial存储库存档到远程目录?例如,如果可以执行以下操作,那就太好了:
hg archive ssh://user@example.com/path/to/archive
Run Code Online (Sandbox Code Playgroud)
但是,这似乎不起作用.它改为创建一个ssh:在当前目录中调用的目录.
我创建了以下快速和脏脚本,通过创建临时ZIP存档,通过SSH复制并解压缩目标目录来模拟所需的行为.但是,我想知道是否有更好的方法.
if [[ $# != 1 ]]; then
echo "Usage: $0 [user@]hostname:remote_dir"
exit
fi
arg=$1
arg=${arg%/} # remove trailing slash
host=${arg%%:*}
remote_dir=${arg##*:}
# zip named to match lowest directory in $remote_dir
zip=${remote_dir##*/}.zip
# root of archive will match zip name
hg archive -t zip $zip
# make $remote_dir if it doesn't exist
ssh $host mkdir --parents $remote_dir
# copy zip over ssh into destination
scp $zip $host:$remote_dir
# unzip into containing directory (will …Run Code Online (Sandbox Code Playgroud)