プロジェクト

全般

プロフィール

Vote #72770

完了

Some unit and functional tests miss fixtures and break when run alone

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

100%

予定工数:
category_id:
30
version_id:
56
issue_org_id:
12285
author_id:
1188
assigned_to_id:
1188
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I develop many plugins these days, and had the surprise to see the test suite run ok on MacOSX and fail on one of my Linux systems (2 functional tests breaking). Same ruby version, gems, codebase, etc. It turns out it's because tests are not run in the same order on both platforms, and it seems some unit and functional tests depend on other tests and fail if the other test doesn't run before.

To be sure I prepared a test database and ran each test alone :


RAILS_ENV=test rake db:drop db:create db:migrate redmine:plugins db:schema:dump db:fixtures:load
cp db/test.sqlite3 db/test.template.sqlite3
for t in test/*/_test.rb; do
cp db/test.template.sqlite3 db/test.sqlite3
RAILS_ENV=test ruby -Itest $t || echo $t |tee -a tmp/failing_alone.txt
done

Here's the list I ended with, I excluded scm related tests because I'm not sure they actually have a problem (tests run against 2.1.0 stable version, results in trunk may differ but it's a looong thing to run) :


test/functional/groups_controller_test.rb
test/functional/issue_categories_controller_test.rb
test/functional/issue_statuses_controller_test.rb
test/functional/mail_handler_controller_test.rb
test/functional/queries_controller_test.rb
test/functional/search_controller_test.rb
test/functional/sessions_test.rb
test/functional/welcome_controller_test.rb
test/integration/api_test/issues_test.rb
test/integration/api_test/users_test.rb
test/integration/issues_test.rb
test/unit/comment_test.rb
test/unit/issue_category_test.rb
test/unit/issue_relation_test.rb
test/unit/issue_test.rb
test/unit/journal_observer_test.rb
test/unit/journal_test.rb
test/unit/lib/redmine/menu_manager/menu_helper_test.rb
test/unit/message_test.rb
test/unit/project_test.rb
test/unit/role_test.rb
test/unit/time_entry_activity_test.rb
test/unit/version_test.rb
test/unit/watcher_test.rb

For most of them I think the fix may be easy, it's just a missing fixture, a coupling with a previous record or a missing setting. I'll try to see what's the problem in each case and commit fixes in trunk as I find them.


journals

OK it's almost only a problem of missing fixtures declarations, sorry for the many small commits. As I started this way I'll continue, unless somebody prefers one bigger commit (too bad I couldn't rebase/reorder locally, yay svn! ;))

Anyway, it might be easier to require @fixtures :all@ in most tests, but it's not possible for now since there are some YAML files in @test/fixtures/@ that are not valid ActiveRecord fixtures. Any thought about this ?
--------------------------------------------------------------------------------
Changed my mind, that was 14 more commits for just fixtures declarations, so I just splitted it into unit/functional/integration, I hope it's fine. Jean-Philippe: I let you merge it when you want, but I'd be happy to have your opinion on "fixtures :all".
--------------------------------------------------------------------------------
Thanks for the fix.

Jean-Baptiste Barth wrote:
> "fixtures :all"

It would slow down the tests quite a bit so I'm not in favour of that.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン2.2.0_56 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0