Rails 3 "rake test" command output - ruby

running "rake test" with a simple Rails 3 project gives me the following output.
Why are two suites listed? I have one default test with "assert true" which is counted in the first suite but not the second.
Any ideas? I know Ruby 1.9 replaced Test::Unit with MiniTest which has caused some issues, but after a few hours Googling I haven't found an explanation for this output.
NOTICE: CREATE TABLE (etc.)
Loaded suite /Users/me/.rvm/gems/ruby-1.9.2-head#rails/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.030670 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 14141
Loaded suite /Users/me/.rvm/gems/ruby-1.9.2-head#rails/bin/rake
Started
Finished in 0.003156 seconds.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 56342

Related

Is there logging statements available for rake test in test-unit using ruby

I am running rake test in ruby.
When I run rake test, I get the following output
rake TEST=test_cases/test.rb
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/bin/ruby -I"helpers" -I"/home/ubuntu/.rvm/gems/ruby-2.0.0-p247#test/gems/rake-10.1.0/lib" "/home/karunakaran/.rvm/gems/ruby-2.0.0-p247#test/gems/rake-10.1.0/lib/rake/rake_test_loader.rb" "test_cases/test.rb"
Loaded suite /home/ubuntu/.rvm/gems/ruby-2.0.0-p247#test/gems/rake-10.1.0/lib/rake/rake_test_loader
Started
.
Finished in 64.385604437 seconds.
1 tests, 16 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
0.02 tests/s, 3.35 assertions/s
I want to get test suite logging at-least minimally instead just showing dot(.) for each test
Test logging like as below or any logging at step by step manner
Testname started
Running testname..
Error will display if we get any error
Testname completed

Jenkins running xcode unit tests not working

I'm trying to configure CI with Jenkins for Xcode. I'm getting the following error in the console. The tests are running and I get a test output with JUnit. However it still says that it cannot runscripts.
Test Suite 'All tests' started at 2013-05-29 23:44:13 +0000
Test Suite '/Users/originate/.jenkins/jobs/Test/workspace/build/Debug-iphonesimulator/HelloWorldTests.octest(Tests)' started at 2013-05-29 23:44:13 +0000
Test Suite 'HelloWorldTests' started at 2013-05-29 23:44:13 +0000
Test Case '-[HelloWorldTests testExample]' started.
Test Case '-[HelloWorldTests testExample]' passed (0.000 seconds).
Test Suite 'HelloWorldTests' finished at 2013-05-29 23:44:13 +0000.
Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite '/Users/originate/.jenkins/jobs/Test/workspace/build/Debug-iphonesimulator/HelloWorldTests.octest(Tests)' finished at 2013-05-29 23:44:13 +0000.
Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'All tests' finished at 2013-05-29 23:44:13 +0000.
Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
Command /bin/sh failed with exit code 1
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution "Run Script" build/HelloWorld.build/Debug-iphonesimulator/HelloWorldTests.build/Script-09E70126174EF7C800DFCE82.sh
(1 failure)
Build step 'Xcode' marked build as failure
Recording test results
Build step 'Upload to Testflight' marked build as failure
Finished: FAILURE
EDIT
The following error is given from running unit tests on command line in addition to the above error:
Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 "Simulator session timed out." UserInfo=0x7fb9d35003a0 {NSLocalizedDescription=Simulator session timed out.}
The script for the unit tests that I am running is:
#!/usr/bin/env ruby
if ENV['SL_RUN_UNIT_TESTS'] then
launcher_path = "ios-sim"
test_bundle_path= File.join(ENV['BUILT_PRODUCTS_DIR'], "#{ENV['PRODUCT_NAME']}.#{ENV['WRAPPER_EXTENSION']}")
environment = {
'DYLD_INSERT_LIBRARIES' => "/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection",
'XCInjectBundle' => test_bundle_path,
'XCInjectBundleInto' => ENV["TEST_HOST"]
}
environment_args = environment.collect { |key, value| "--setenv #{key}=\"#{value}\""}.join(" ")
app_test_host = File.dirname(ENV["TEST_HOST"])
passed = system("#{launcher_path} launch \"#{app_test_host}\" #{environment_args} --args -SenTest All #{test_bundle_path}")
exit(1) if !passed
exit 0
else
puts "SL_RUN_UNIT_TESTS not set - Did not run unit tests!"
exit 0
end
Please help me out.
Thanks!

Ruby 1.9.3 doesn't run any unit tests when run in parallel

When run in parallel, Ruby 1.9.3 doesn't run any unit tests
Given the following code,
# Modified from https://gist.github.com/1334056/121396125ca4dd7ee1bb81536cce0754700f20fb
# replication.rb
require 'test/unit'
class TestTest < Test::Unit::TestCase
def test_one
assert true
end
def test_two
assert true
end
end
unit testing works when it's not run in parallel, but doesn't work when it's run in parallel:
$ ruby1.9.1 replication.rb
Run options:
# Running tests:
..
Finished tests in 0.000348s, 5740.7094 tests/s, 5740.7094 assertions/s.
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
$ ruby1.9.1 replication.rb --jobs=2 --ruby /usr/bin/ruby1.9.1
Run options: --jobs=2 --ruby /usr/bin/ruby1.9.1
# Running tests:
Retrying...
Finished tests in 0.039012s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
For what it's worth, here's what happens when the debugging switch is on:
$ export RUBYOPT="-d"
$ ruby1.9.1 replication.rb
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1243 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby
Run options:
# Running tests:
..
Finished tests in 0.000350s, 5718.3539 tests/s, 5718.3539 assertions/s.
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
$ ruby1.9.1 replication.rb --jobs=2 --ruby /usr/bin/ruby1.9.1
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1243 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby
Run options: --jobs=2 --ruby /usr/bin/ruby1.9.1
# Running tests:
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1243 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1243 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/lib/ruby/1.9.1/rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby
/usr/lib/ruby/1.9.1/test/unit/parallel.rb:149: warning: method redefined; discarding old on_parallel_worker?
/usr/lib/ruby/1.9.1/test/unit/testcase.rb:11: warning: previous definition of on_parallel_worker? was here
/usr/lib/ruby/1.9.1/test/unit/parallel.rb:149: warning: method redefined; discarding old on_parallel_worker?
/usr/lib/ruby/1.9.1/test/unit/testcase.rb:11: warning: previous definition of on_parallel_worker? was here
Exception `Errno::EPIPE' at /usr/lib/ruby/1.9.1/test/unit/parallel.rb:125 - Broken pipe - <STDOUT>
Exception `Errno::EPIPE' at /usr/lib/ruby/1.9.1/test/unit/parallel.rb:133 - Broken pipe - <STDOUT>
Retrying...
Finished tests in 0.033203s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
I also tried requiring minitest, but that didn't have parallel testing available:
# mini_me.rb
# modified from http://apidock.com/ruby/MiniTest
require 'minitest/autorun'
class TestMeme < MiniTest::Unit::TestCase
def test_one
assert true
end
def test_two
assert true
end
end
gives
$ ruby1.9.1 mini_me.rb --help
minitest options:
-h, --help Display this help.
-s, --seed SEED Sets random seed
-v, --verbose Verbose. Show progress processing files.
-n, --name PATTERN Filter test names on pattern.
And here's the version of Ruby and ubuntu.
$ ruby1.9.1 --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ uname -a
Linux [redacted] 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
I've also run the first script using a recent commit of Ruby on OS X snow leopard (ruby 2.0.0dev (2012-05-05 trunk 35543) [x86_64-darwin10.8.0]), and it didn't work there.
What am I doing wrong?
The following happens when I have multiple files, but don't explicitly use Test::Unit::Runner
test1.rb
require "test/unit"
class Test1 < Test::Unit::TestCase
def test_one
assert true
end
end
test2.rb
require "test/unit"
class Test2 < Test::Unit::TestCase
def test_two
assert true
end
end
test_all.rb
require_relative "test1"
require_relative "test2"
Trying using this approach:
$ ruby test_all.rb --basedir=. --jobs 2 --ruby /Users/agrimm/.rvm/rubies/ruby-head/bin/ruby
Run options: --basedir=. --jobs 2 --ruby /Users/agrimm/.rvm/rubies/ruby-head/bin/ruby
# Running tests:
Retrying...
Finished tests in 0.075256s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.0.0dev (2012-05-05 trunk 35543) [x86_64-darwin10.8.0]
I'm sora_h a maintainer of test/unit.
test/unit parallelizes for each test file.
You need to separate test file and TestCase to parallelize.
Sorry for inconvenience, but we can't parallelize for each test_* methods because there are some test_* methods can't run separately. (needs to be ordered)
You can use Test::Unit::Runner to run multiple files.
Thank you.

Why are my specs while using Guard so slow?

When I run my specs using just spork, I get quite a significant performance increase
$ time rspec .
.....
Finished in 11.39 seconds
5 examples, 0 failures
real 0m11.780s
user 0m10.318s
sys 0m1.180s
and with spork
$ time rspec . --drb
.....
Finished in 107.24 seconds
5 examples, 0 failures
real 0m1.968s
user 0m0.488s
sys 0m0.095s
which is really awesome. But once I put guard into play, it seems that everything runs so slow, as if there was no spork at all.
$ guard
Guard is now watching at '/Users/darth/projects/scvrush'
Starting Spork for RSpec
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running all specs
.....
Finished in 10.77 seconds
5 examples, 0 failures
even if I don't look at the Finished in 10.77 seconds, I can count at least 6-8 seconds every time it tries to run a spec, even for just one model.
I did some minor edits to the Guardfile, such as :wait => 120, but that should only affect when guard is starting up.
You have to pass the --drb option for rspec in your Guardfile, like this:
guard 'rspec', :version => 2, :cli => '--drb' do
...
end

selenium rc with cruise control - testng error message - could not instantiate 'test'

I'm currently trying to set up cruisecontrol to run my selenium test suite. Everything works fine until I run the build, I got the following message:
calling target(s) [execute-test] in build file C:\Project\src\build.xml
Entering C:\Project\src\build.xml...
Exiting C:\Project\src\build.xml.
task location="C:\Project\src\build.xml:30: " name="antcall" time="0 seconds"
target name="execute-test" time="0 seconds"
task location="C:\Project\src\build.xml:37: " name="testng" time="0 seconds"
Executing 'C:\Program Files (x86)\Java\jdk1.6.0_06\jre\bin\java.exe' with arguments:
'-ea'
'-classpath'
'C:\testng;C:\testng\testng-5.9-jdk15.jar;C:\testng\commons-lang-2.0.jar;C:\testng\testng-5.9-jdk14.jar'
'org.testng.TestNG'
'#C:\DOCUME~1\SERVER~1\LOCALS~1\Temp\1\testng10509'
The ' characters around the executable and arguments are
not part of the command.
[Parser] Running:
C:\Project\src\TestSuite.xml
[TestRunner] Running the tests in 'testInpagePlacement' with parallel mode:false
[RunInfo] Adding method selector: org.testng.internal.XmlMethodSelector#9664a1 priority: 10
[ClassHelper] Could not instantiate testcase1: testcase1
[ClassHelper] Could not instantiate testcase1: testcase1
===============================================
[Smoke test]
[Total tests run: 0, Failures: 0, Skips: 0]
===============================================
[org.testng.TestNGException:]
[Cannot find class in classpath: testcase1]
at org.testng.xml.XmlClass.getSupportClass(XmlClass.java:55)
at org.testng.internal.Utils.xmlClassesToClasses(Utils.java:79)
at org.testng.TestRunner.initMethods(TestRunner.java:289)
at org.testng.TestRunner.init(TestRunner.java:235)
at org.testng.TestRunner.init(TestRunner.java:197)
at org.testng.TestRunner.(TestRunner.java:141)
at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:488)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:250)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877)
at org.testng.TestNG.runSuitesLocally(TestNG.java:842)
at org.testng.TestNG.run(TestNG.java:751)
at org.testng.TestNG.privateMain(TestNG.java:914)
at org.testng.TestNG.main(TestNG.java:887)
The tests failed.
This was run on a network server, I'd tested the testsuite.xml locally through intellij and everything works fine. I feel like this is a config issue with the network server, please let me know if my assumption is wrong and point me to the right direction to fix this issue.
Thanks.
You don't have your classes (tests & target classes) on the classpath.

Resources