How to create functional tests for a Redmine 3 plugin
Added by Anonymous almost 8 years ago
Hi ! I have created few Redmine 3 plugins and now I want to code the tests to ensure a better stability if possible.
But now I can't create anything that works, I tried to look at other plugin's tests, and I can't reproduce things to work in any way possible.
You guys can give me a simple canvas example of how to proceed ?
I actually created
redmine/plugins/redmine_timebank/test/functional/timebank_helper_test.rbcontaining this :
require 'redmine' require 'versions_controller' class TimebankHelperTest < ActionController::TestCase fixtures :projects, :issues, :issue_statuses, :versions, :trackers, :projects_trackers, :issue_categories, :time_entries def setup @controller = VersionsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new User.current = User.where(:admin => true).first @request.session[:user_id] = User.current.id @project = Project.find(1) end def test_timebank_table puts "AWWWWWWWWWWWWWWWWWWWW YEAHHHHHHHHHHHHHHHHHHHHH !" end end
But when I execute the command :
RAILS_ENV=test bin/rake redmine:plugins:test --trace
I get those errors :
** Execute redmine:plugins:test:functionals /usr/bin/ruby2.3 -I"lib:test" "/usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb" "plugins/*/test/functional/**/*_test.rb" /usr/share/redmine/lib/redmine/core_ext/active_record.rb:18:in `<top (required)>': uninitialized constant ActiveModel (NameError) from /usr/share/redmine/lib/redmine/core_ext.rb:1:in `require' from /usr/share/redmine/lib/redmine/core_ext.rb:1:in `block in <top (required)>' from /usr/share/redmine/lib/redmine/core_ext.rb:1:in `each' from /usr/share/redmine/lib/redmine/core_ext.rb:1:in `<top (required)>' from /usr/share/redmine/lib/redmine.rb:18:in `require' from /usr/share/redmine/lib/redmine.rb:18:in `<top (required)>' from /usr/share/redmine/plugins/redmine_timebank/test/functional/timebank_helper_test.rb:1:in `require' from /usr/share/redmine/plugins/redmine_timebank/test/functional/timebank_helper_test.rb:1:in `<top (required)>' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:10:in `require' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:9:in `each' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:9:in `block in <main>' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:4:in `select' from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:4:in `<main>' rake aborted!
Seeing
uninitialized constant ActiveModel (NameError)make me thinks that I need more depedencies, but I tough that I just need to require redmine to all import the rest.
Other plugins seems to import some thing like in their test/test_helper.rb :
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
And this line into each testing file :
require File.dirname(__FILE__) + '/../test_helper'
Rake test says that none of those importing files could be found. Such as :
/usr/share/redmine/plugins/redmine_timebank/test/test_helper.rb:1:in `require': cannot load such file -- /usr/share/redmine/test/test_helper (LoadError)
Which stuff I do need to import into my functional test in order to get it works ?
Is this
test/test_helperstill exists ? Where can I find it ?
Thank you very much and have a great day !