activerecord-jdbc-adapter icon indicating copy to clipboard operation
activerecord-jdbc-adapter copied to clipboard

Make tests runnable without Rake to enable (IDE) debugging

Open donv opened this issue 9 years ago • 4 comments

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?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/24030738-make-tests-runnable-without-rake-to-enable-ide-debugging?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github).

donv avatar Jul 09 '15 19:07 donv

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.

donv avatar Jul 11 '15 05:07 donv

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.

kares avatar Jul 11 '15 11:07 kares

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?

donv avatar Jul 12 '15 21:07 donv

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=...

kares avatar Jul 28 '15 05:07 kares