Support fast unit tests in EE
Problem to solve
We have fast unit tests available when dealing with POROs but this currently only works for CE classes.
Intended users
GitLab developers
Further details
Trying to run a "fast spec" for an EE class by requiring fast_spec_helper
instead of spec_helper
will raise error:
Failure/Error: StubConfiguration.prepend(EE::StubConfiguration)
NameError:
uninitialized constant EE::StubConfiguration
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
# ./spec/support/helpers/stub_configuration.rb:124:in `<main>'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
# ./spec/support/rspec.rb:1:in `<main>'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
# ./spec/fast_spec_helper.rb:7:in `<main>'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
# ./ee/spec/lib/gitlab/ci/reports/security/locations/sast_spec.rb:3:in `<main>'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/nakayoshi_fork-0.0.4/lib/nakayoshi_fork.rb:23:in `fork'
# /Users/ogonzalez/.rvm/gems/ruby-2.5.3/gems/nakayoshi_fork-0.0.4/lib/nakayoshi_fork.rb:23:in `fork'
# -e:1:in `<main>'
Proposal
TODO
Documentation
We might need to improve https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#fast-unit-tests if there is a specific setup for EE.
What does success look like, and how can we measure that?
One can use fast unit tests for EE classes.
Links / references
Edited by Olivier Gonzalez