[Nitro] [Bug]? Only one test per test case?
Humber Aquino
humberaquino at gmail.com
Thu Apr 27 16:07:49 EDT 2006
This configuration let me have just one test per test case.
The User model model:
class User
property :name, String
end
The test case file:
require 'test/unit'
require 'glue/fixture'
require 'og/test'
require 'src/model/user'
class TestCaseUser < Test::Unit::TestCase
def setup
@og = Og.setup(
:destroy => true,
:store => :mysql,
:name => 'db_test',
:user => 'dbuser',
:password => 'dbpass'
)
og_fixture User
end
def test_something
assert_kind_of User, @some_user
end
end
When i run this test i get this result:
$ ruby test/tc_user.rb
Loaded suite test/tc_user
Started
I, [2006-04-26T13:03:44.421900 #12824] INFO -- : Og uses the Mysql store.
Database "db_test" dropped
I, [2006-04-26T13:03:44.493233 #12824] INFO -- : Database 'db_test' not
found!
I, [2006-04-26T13:03:44.617892 #12824] INFO -- : Created table 'oguser'.
.
Finished in 0.218669 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
Thats ok. But when i add other test to this test case, for example:
def test_something_else
assert_equal @some_user.name, 'John Doe'
end
Tthe result is this one:
$ ruby test/tc_user.rb
Loaded suite test/tc_user
Started
I, [2006-04-26T13:05:48.496080 #12883] INFO -- : Og uses the Mysql store.
Database "db_test" dropped
I, [2006-04-26T13:05:48.581070 #12883] INFO -- : Database 'db_test' not
found!
I, [2006-04-26T13:05:48.694901 #12883] INFO -- : Created table 'oguser'.
.I, [2006-04-26T13:05:48.711974 #12883] INFO -- : Og uses the Mysql store.
Database "db_test" dropped
I, [2006-04-26T13:05:48.754274 #12883] INFO -- : Database 'db_test' not
found!
E, [2006-04-26T13:05:48.838177 #12883] ERROR -- : DB error Table
'db_test.oguser' doesn't exist, [SELECT * FROM oguser WHERE name = 'John
Doe']
E, [2006-04-26T13:05:48.838573 #12883] ERROR -- :
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/mysql.rb:166:in
`query'/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/mysql.rb:166:in
`query'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/sql.rb:464:in `find_one'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:565:in `finder'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:461:in
`method_missing'
./src/model/user.rb:28:in `validate'
/usr/lib/ruby/gems/1.8/gems/glue-0.29.0/lib/glue/validation.rb:156:in
`valid?'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store.rb:99:in `save'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:32:in `save'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/test/testcase.rb:46:in
`og_fixture'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/test/testcase.rb:45:in
`og_fixture'
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/test/testcase.rb:42:in
`og_fixture'
test/tc_user.rb:19:in `setup'
/usr/lib/ruby/1.8/test/unit/testcase.rb:69:in `run'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'
/usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:44:in `run_suite'
/usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:65:in `start_mediator'
/usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:39:in `start'
/usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:27:in `run'
/usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run'
/usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'
/usr/lib/ruby/1.8/test/unit.rb:285
test/tc_user.rb:26
/usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/sql.rb:883:in
`handle_sql_exception': Og::StoreException (Og::StoreException)
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/mysql.rb:168:in
`query'
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store/sql.rb:464:in
`find_one'
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:565:in
`finder'
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:461:in
`method_missing'
from ./src/model/user.rb:28:in `validate'
from /usr/lib/ruby/gems/1.8/gems/glue-0.29.0/lib/glue/validation.rb:156:in
`valid?'
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/store.rb:99:in
`save'
from /usr/lib/ruby/gems/1.8/gems/og-0.29.0/lib/og/entity.rb:32:in
`save'
... 13 levels...
from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run'
from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'
from /usr/lib/ruby/1.8/test/unit.rb:285
from test/tc_user.rb:26
I looks like Og setup runs correctly only once. then it doesn't create the
db structure again.
How can i fix this? am i missing somethig?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20060427/7c07311f/attachment.html
More information about the Nitro-general
mailing list