变异测试:有人知道突变体吗?

时间:2013-06-09 06:12:22

标签: ruby unit-testing testing rspec mutation-testing

昨天在变异测试的这个article中发现了一个绊脚石,我立即尝试了elasticrepo一个lib,我正在写一篇关于弹性搜索的索引github。

不幸的是,我似乎错过了一些东西,因为我没有得到任何所谓的“Killed:rspec”和零突变:

lsoave@ubuntu:~/rails/github/elasticrepo$ mutant -I lib/elasticrepo -r repo_subset --rspec-dm2 ::RepoSubset
Mutant configuration:
Matcher:   #<Mutant::Matcher::ObjectSpace scope_name_pattern=/\ARepoSubset(\z|::)/>
Filter:    Mutant::Mutation::Filter::ALL
Strategy:  #<Mutant::Strategy::Rspec::DM2>

subjects:   0
mutations:  0
noop_fails: 0
kills:      0
alive:      0
mtime:      0.00s
rtime:      0.01s
lsoave@ubuntu:~/rails/github/elasticrepo$ 

现在我认为它可能与路径有关,然后在这种情况下就是这样:

lsoave@ubuntu:~/rails/github/elasticrepo$ ls -l lib/elasticrepo
total 16
-rw-rw-r-- 1 lsoave lsoave  333 Jun  8 16:07 extractor.rb
-rw-rw-r-- 1 lsoave lsoave 1960 Jun  8 16:07 indexer.rb
-rw-rw-r-- 1 lsoave lsoave 1330 Jun  8 16:07 repo_subset.rb
-rw-rw-r-- 1 lsoave lsoave   43 Jun  1 12:28 version.rb
lsoave@ubuntu:~/rails/github/elasticrepo$ 

这里是要测试的类的“结构”(就命名空间而言):

lsoave@ubuntu:~/rails/github/elasticrepo$ head -2 lib/elasticrepo/repo_subset.rb
module Elasticrepo
  class RepoSubset
lsoave@ubuntu:~/rails/github/elasticrepo$ 

请随意查看整个代码以测试变异:elasticrepo

由于响应行:

,正则表达式也可能出现问题
Matcher:   #<Mutant::Matcher::ObjectSpace scope_name_pattern=/\ARepoSubset(\z|::)/>

有人可以为此提供帮助吗?

1 个答案:

答案 0 :(得分:4)

免责声明:此处突变的作者。

刚刚克隆了你的回购。需要进行更改:

  • Mutant目前仅在mri-1.9.3和rbx 19-mode下运行。我很快就将它移植到2.0.0。
  • 指定完全限定的常量名称::Elasticrepo::RepoSubset,而不是::RepoSubset
  • 另请注意,对于当前的突变版本,标记--rspec-dm2已被替换为--use rspec

使用此更改,Mutant可以正确运行。

快乐变异!

相关问题