..results deleted...
8 tests, 0 assertions, 0 failures, 16 errors
/usr/local/ror/bin/ruby -Ilib:test "/usr/local/ror/lib/ruby/gems/1.8/gems/rake-0.7.0/
lib/rake/rake_test_loader.rb"
rake aborted!
Test failures
(See full trace by running task with --trace)
可以看到有一些问题存在:rake 生成了 16 个错误。跟踪显示,Rails 无法建立连接。我忘记启动数据库引擎了。我将启动数据库引擎,然后再次运行 rake。这次我得到了清单 2 所示的结果:
清单 2. 在 rake 内通过测试
rake
(in /Users/batate/rails/trails)
/usr/local/ror/bin/ruby -Ilib:test
"/usr/local/ror/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader.rb"
"test/unit/trail_test.rb"
Loaded suite /usr/local/ror/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader
Started
...
Finished in 0.09541 seconds.
3 tests, 5 assertions, 0 failures, 0 errors
/usr/local/ror/bin/ruby -Ilib:test
"/usr/local/ror/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader.rb"
"test/functional/trails_controller_test.rb"
Loaded suite /usr/local/ror/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader
Started
........
Finished in 0.169756 seconds.
8 tests, 28 assertions, 0 failures, 0 errors
这样就好多了。测试正常运行,而我们准备构建更多测试用例。如果仔细查看清单 2 就会发现,rake 生成了两组结果。第一组(第 1 部分的单元测试)看起来应当熟悉。下一组是从框架中自动生成的功能测试。
文章来源于领测软件测试网 https://www.ltesting.net/