activerecord-jdbc-adapter
activerecord-jdbc-adapter copied to clipboard
Make tests runnable without Rake to enable (IDE) debugging
We are able to run a single test using for example:
rake test_derby TEST=test/db/derby/simple_test.rb TESTOPTS="--name=/test_count_with_limit/"
This also works in an IDE like Rubymine. However running a single test the regular way fails:
$ jruby test/db/derby/simple_test.rb --name=test_count_with_limit
LoadError: no such file to load -- db/derby
require at org/jruby/RubyKernel.java:1072
require at /Users/uwe/.rvm/rubies/jruby-1.7.20/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
(root) at /Users/uwe/workspace/jruby/activerecord-jdbc-adapter/test/db/derby/test_helper.rb:1
require at org/jruby/RubyKernel.java:1072
(root) at /Users/uwe/.rvm/rubies/jruby-1.7.20/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at test/db/derby/simple_test.rb:2
Also running the Rake task with debug enabled fails to stop at break points (at least in my environment).
This makes it very hard to debug and develop the code base.
Is there anything I can do to make debugging with break points work in the current code base?
If not, can we change the test setup to allow running tests directly by loading the test files?
I have a proof of concept for making the tests runnable both from Rake and stand alone. It involves requiring ``test/test_helper` in every test file you want to be runnable.
rake is needed to setup the path to ROOT/jdbc-derby ... otherwise running single file tests using rake test_derby TESTOPTS="--name=/int/"
... would prefer to not default to LOAD_PATH manipulation in test helper so manually one can still test against different driver versions.
OK, how about adding the path to the test directory and lib directory at least to be able to load the code and tests, and then load the driver files based on an environment variable like ARJDBC_TEST_DRIVER?
How do you usually set what driver version you want to test against?
usually with a local Gemfile for running the whole suite using rake test_xxx
or for running single tests with the load path: ruby -Ilib:test:../driver_path: test/db/mysql/simple_test.rb --name=...