昨天在这个article 中绊了一跤在突变测试上并立即尝试了 elasticrepo我写的一个库,用于在 elasticsearch 上索引 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|::)/>
有人可以帮忙吗?
最佳答案
免责声明:这里是突变体的作者。
刚刚克隆了您的存储库。需要更改:
- Mutant 目前仅在 mri-1.9.3 和 rbx 19-模式下运行。我会尽快将其移植到 2.0.0。
- 指定完全限定的常量名称,
::Elasticrepo::RepoSubset
而不是::RepoSubset
- 另请注意,对于当前的变体版本,标志
--rspec-dm2
被简单地替换为--use rspec
Mutant 确实可以通过此更改正确运行。
快乐的变异!
关于ruby - 突变测试 : does anybody know mutant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17006961/